dta1 <- read.table(file="http://www.ccunix.ccu.edu.tw/~psycfs/dataM/Data/brainsize.txt",
h=T,sep="")
#3head(dta1)
library(lattice);library(reshape2)
dta1a <- melt(dta1[,1:5],id=c("Sbj","Gender"));colnames(dta1a)[3:4] <- c("IQ","Score")
bwplot(Score~Gender|IQ,
data=dta1a,layout=c(3,1),
par.settings = list(box.rectangle = list(fill= c('red','blue'))))
dta1b <- aggregate(dta1a,list(dta1a$Gender,dta1a$IQ),mean)
# I try to plot the error, but it seem difficult to dodge the error bars position.
dotplot(Score ~ Group.1,group=Group.2,data = dta1b,type=c("p","l","g"),
pch = 16, cex = 1.2,
auto.key=list(space="right",points = T, lines = T, rows = 3),
xlab = "Gender", ylab = "IQ score",
par.settings = simpleTheme(col = c("blue", "red","green"), pch = 19,
col.line = c("blue", "red","green")))
2.
xyplot(Weight~Height,group=Gender,
data=dta1,type = c("p", "r", "g"),
auto.key = list(points = T, lines = T, space="top"),
par.settings = simpleTheme(col = c("blue", "red"), pch = 19,
col.line = c("blue", "red")))
3.
splom( MRICount~ cbind(FSIQ, VIQ, PIQ),
group=Gender,data=dta1,pscale=0,type=c("g","p","r"),
par.settings = simpleTheme(col = c("blue", "red"), pch = 21,
col.line = c("blue", "red") ))
# or use xyplot
dta2 <- read.table(file="http://www.ccunix.ccu.edu.tw/~psycfs/dataM/Data/boyHeights.txt",
h=T,sep="")
xyplot(ht~(age+13),data=dta2,group=sbj,type=c("p","l"),lty=2,
xlab="Age (in year)",ylab="Height (in cm)")
# But I can't mimic the original color in the demo plot.
dta3 <- read.table(file="http://www.ccunix.ccu.edu.tw/~psycfs/dataM/Data/beautyCourseEval.txt",
h=T,sep="")
# I am not sure what the dotted line mean (but not the confident interval) .
xyplot(eval~beauty,data=dta3,type=c("p","r"),
panel=function(x, y) {
panel.xyplot(x, y)
panel.abline(lm((y+sd(y)) ~ x),lty=2)
panel.abline(lm((y-sd(y)) ~ x),lty=2)
panel.abline(lm(y ~ x))},
par.settings = simpleTheme(col = "black", col.line = "black"),
scales = list(x=list(at=seq(-1.5,2.0,by=0.5),labels=seq(-1.5,2.0,by=0.5))),
xlab="Beauty score",
ylab="Average teaching evaluation")
xyplot(eval~beauty|as.factor(courseID),data=dta3,layout=c(6,6),type=c("p","r"),
par.settings = simpleTheme(col.line = "black"),
xlab="Beauty judgement score",
ylab="Average course evaluation score")