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 Moodle. Please make sure that this link is hyperlinked and that I can see the visualization and the code required to create it.
# place the code to simulate the data here
set.seed(30)
rnorm(30,{1;2;3},{2;3;4})
## [1] -2.15407280 1.60924238 0.91348460 8.09389266 10.29808241
## [6] -3.04523176 3.44203218 -0.04318491 0.32041193 4.09807875
## [11] -1.09308808 -4.27759163 0.32884076 2.76280803 6.52066366
## [16] 4.07405167 2.92168248 0.90021211 -2.63732573 -4.33595686
## [21] 2.36674282 6.01770628 -0.64851850 6.19972456 8.96221200
## [26] -1.38560796 0.86311725 -2.68481211 -1.97095321 3.92774471
# place the code to simulate the data here
x = rnorm(20,1,1)
y = rnorm(20,1,1)
plot(y~x)
# place the code to simulate the data here
set.seed(60)
x1 = runif(20,1,10)
x2 = runif(20,1,10)
y = rnorm(20,1,2)
lm(y ~x1+x2)
##
## Call:
## lm(formula = y ~ x1 + x2)
##
## Coefficients:
## (Intercept) x1 x2
## 1.51014 -0.17695 0.09951
# place the code to simulate the data here
rep(letters[1:3],each=2,times=2)
## [1] "a" "a" "b" "b" "c" "c" "a" "a" "b" "b" "c" "c"
# place the code to simulate the data here
data.frame(group = rep(letters[1:3],len=25), factor =rep(letters[4:5],len=25),x = rnorm(25,1,0),y = rnorm(25,1,3))
## group factor x y
## 1 a d 1 6.4821970
## 2 b e 1 4.5946001
## 3 c d 1 2.2174087
## 4 a e 1 2.1899092
## 5 b d 1 2.6963196
## 6 c e 1 4.1045987
## 7 a d 1 -5.4641049
## 8 b e 1 1.2129215
## 9 c d 1 7.4899001
## 10 a e 1 3.7008975
## 11 b d 1 6.1281422
## 12 c e 1 5.8634388
## 13 a d 1 4.2306583
## 14 b e 1 0.8343692
## 15 c d 1 2.4131684
## 16 a e 1 -3.1830700
## 17 b d 1 0.1061153
## 18 c e 1 0.9285322
## 19 a d 1 -0.7901686
## 20 b e 1 1.1864725
## 21 c d 1 0.9632911
## 22 a e 1 -2.8540697
## 23 b d 1 -1.9351122
## 24 c e 1 -4.1357237
## 25 a d 1 4.5117658