knitr::include_graphics("Inclass3.png")knitr::include_graphics("Inclass4-1.png")knitr::include_graphics("Inclass4-2.png")chem97.R histograms and density plots
# histograms and density plotsinstall.packages("mlmRev", repos='https://cloud.r-project.org')## 將程式套件安載入 'C:/Users/Lightmann/Documents/R/win-library/4.1'
## (因為 'lib' 沒有被指定)
## package 'mlmRev' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\Lightmann\AppData\Local\Temp\RtmpwDXjYG\downloaded_packages
library(mlmRev)## 載入需要的套件:lme4
## 載入需要的套件:Matrix
library(lattice)dta <- Chem97dta$age = dta$age + 18.5histogram(~gcsescore | factor(score), data=dta)tp1 <- histogram(~gcsescore | factor(score), data=dta)tp2 <- densityplot(~ gcsescore,
groups=score,
data=dta,
plot.points=F,
auto.key=list(space="right",title="score"))## (col.position, row.position, n.col, n.row)
plot(tp1, split=c(1,1,1,2))## put the second trellis obj at row 2
plot(tp2, split=c(1,2,1,2), newpage=F)