This is the second part of HW1.
Ten subjects read a paragraph consisting of seven sentences. The reading time (in seconds) for each sentence was the outcome measure. The predictors are the serial position of the sentence (Sp), the number of words in the sentences (Wrds), and the number of new arguments in the sentence (New). Use the data file below to estimate, on average, how long does it take to read a word.
dta<-read.table("readingtimes.txt",h=T)
time<-dta[,5:14]
word<-dta[,3]
time<-dta[,5:14]
word<-dta[,3]
mean(as.matrix(time/word))
[1] 0.3783395
Use the singer{lattice} data set in the package ‘lattice’ to reproduce the plot below.
library(lattice)
library(ggplot2)
ggplot(data=singer,aes(x=voice.part,y=height),group=reorder(voice.part,height),shape=reorder(voice.part,height,mean))+
stat_summary(fun.y=mean,geom='point',size=4, pch=1, colour='steelblue')+labs(y='Mean height')+
geom_smooth(method = "lm",aes(group=1),se = FALSE)+
theme(
axis.text = element_text(size = 14,colour="black"),
panel.grid.major = element_line(colour = "gray"),
panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "white",colour="black")
)