Posts

Showing posts from October, 2021

Module 9

Image
Module 9 Remarks: The above screenshots capture the immediate resultant tables, code, and console output for the code given for the module 9 assignment. You can watch as the assignment progresses the same processes that were introduced t the beginning are expanded upon and more engaging with a finer scope for editing, cleaning and manipulating data.  Module 9 Code: #Module 9 Assignment #Question 1 assignment_data <- data.frame( Country = c("France","Spain","Germany","Spain","Germany", "France","Spain","France","Germany","France"), age = c(44,27,30,38,40,35,52,48,45,37), salary = c(6000,5000,7000,4000,8000), Purchased=c("No","Yes","No","No","Yes", "Yes","No","Yes","No","Yes")) #Question 2 assignment9 <- table(mtcars$gear, mtcars$cyl, dnn=c("gears")) #Question 2.1 addmargins(

Module 8

 #Module 8 Assignment ##Question 1 ##Data input for stress level vectors HighStress <- c(10,9,8,9,10,8) ModerateStress <- c(8,10,6,7,8,8) LowStress <- c(4,6,6,4,2,2) #generate data frame to help incorpirate all three variables stress <- data.frame(cbind(HighStress, ModerateStress, LowStress)) stressStack <- stack(stress) #Next, I will run an ANOVA test on the dataframe created from the inital data for each stress level oneway.test(values~ind,data = stressStack) ## Remember this assumes a non-equal variance (note to self: See personal notepad as to why) #Next WE will perform an ANOVA test o the data derived from the initial Stress level vectors aovResult <- aov(values~ind,data = stressStack) summary(aovResult) ##Key for results in Console #df = degrees of freedom #SumSq = Sum of the Squares from the variable #Mean sq = sum sq / df #F-Value = mean sq var / mean sq residual #p-value associated with the f-value denoted by Pr(>F) # Because the p-value is less than a 0.0

Module 7 Assignment

Module 7 Assignment  R Code: # Module 7 Assignment #1.1 #First define the data set required, I/O values x <- c(16, 17, 13, 18, 12, 14, 19, 11, 11, 10) y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48) #Then we must create the relationship (correlation) cor(x,y) #This value 0.728 that is in the console tells us a few things #This relationship is correlated and is increasing linearly #I may choose to plot these findings using plot() plot(x,y) #See the lower righthand window for a composite plot for this data, as the regression trednline would positively increase through the points #1.2 #This settion of code will get the value for the coefficients of the linear regression for this data Regression_model=lm(y~x) Regression_model$coefficients #2.1 #This problem will go over the aquisition of similar values with a different data set discharge <- c(3.600,1.800,3.333,2.283,4.533,2.883) waiting <- c(79,54,74,62,85,55) plot(discharge,waiting) #2.1 Regression_model_1=lm(waiting~discharge)