The objective of this assignment is to introduce you to R and R markdown and to complete some basic data simulation exercises.
Please include all code needed to perform the tasks. This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
To submit this homework you will create the document in Rstudio, using the knitr package (button included in Rstudio) and then submit the document to your Rpubs account. Once uploaded you will submit the link to that document on Canvas. Please make sure that this link is hyperlinked and that I can see the visualization and the code required to create it.
set.seed(100)
rnorm(30,mean=c(0,20,40),sd=c(10,20,30))
## [1] -5.0219235 22.6306233 37.6324873 8.8678481 22.3394254 49.5589026
## [7] -5.8179068 34.2906542 15.2422172 -3.5986213 21.7977229 42.8882338
## [13] -2.0163395 34.7968100 43.7013850 -0.2931671 12.2229151 55.3256877
## [19] -9.1381419 66.2059365 26.8573006 7.6406062 25.2392258 63.2021379
## [25] -8.1437912 11.2309886 18.3933535 2.3094453 -3.1545892 47.4122798
x=rnorm(20,mean=10,sd=1)
y=rnorm(20,mean=20,sd=2)
plot(y~x)
x1=runif(50,1,15)
x2=runif(50,50,100)
y=rnorm(50,0,1)
a=lm(y~x1+x2)
a
##
## Call:
## lm(formula = y ~ x1 + x2)
##
## Coefficients:
## (Intercept) x1 x2
## 0.123977 0.020337 -0.004282
rep(letters[2:4],each=2,times=2)
## [1] "b" "b" "c" "c" "d" "d" "b" "b" "c" "c" "d" "d"
data.frame(group=rep(LETTERS[3:5], length.out=27), factor=rep(letters[12:13], length.out=27), response1=rnorm(27, mean=1, sd=2), response2=rnorm(27, mean=2, sd=3))
## group factor response1 response2
## 1 C l 2.26414812 2.4858236
## 2 D m 1.40282705 -1.2563587
## 3 E l 0.81785871 3.7308119
## 4 C m 1.57896825 2.0845153
## 5 D l 0.89063012 0.9298898
## 6 E m -3.08369971 4.5578791
## 7 C l 1.71673848 3.5400957
## 8 D m 0.25479830 5.0546090
## 9 E l 3.53661768 -1.0644373
## 10 C m 5.33720063 0.3149952
## 11 D l -1.47944568 -1.0376682
## 12 E m 2.17974778 -7.0624429
## 13 C l 1.24803858 2.9970508
## 14 D m -0.04741557 5.7215347
## 15 E l 2.24045601 4.0140488
## 16 C m 2.41644317 -1.9901023
## 17 D l 0.81360330 -0.5517409
## 18 E m 0.40960660 -3.3664922
## 19 C l -1.17163046 5.6945657
## 20 D m -0.24963011 0.9968010
## 21 E l 0.53398691 -0.9019663
## 22 C m 0.49836627 4.6381110
## 23 D l 2.90779067 1.2392639
## 24 E m 0.46805499 -2.5536274
## 25 C l 4.79055189 1.9283502
## 26 D m 0.14001835 2.0799784
## 27 E l 4.15109399 2.4910436