HW 3

loading data and check data structure

##   lang   IQ class GS SES COMB
## 1   46 15.0   180 29  23    0
## 2   45 14.5   180 29  10    0
## 3   33  9.5   180 29  15    0
## 4   46 11.0   180 29  23    0
## 5   20  8.0   180 29  10    0
## 6   30  9.5   180 29  10    0
## 'data.frame':    2287 obs. of  6 variables:
##  $ lang : int  46 45 33 46 20 30 30 57 36 36 ...
##  $ IQ   : num  15 14.5 9.5 11 8 9.5 9.5 13 9.5 11 ...
##  $ class: Factor w/ 133 levels "180","280","1082",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ GS   : int  29 29 29 29 29 29 29 29 29 29 ...
##  $ SES  : int  23 10 15 23 10 10 23 10 13 15 ...
##  $ COMB : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...

data manipulation

plot

HW 5

download the zip file online and unzip it

data manipulation

plot

xtick<-seq(0, 40, by=5)
ytick<-seq(.00, 1.00, by=.2)
plot.new()
par(mar=c(2,2,2,3), oma=c(5,5,5,5))
plot(0,type='n', xaxs="i", yaxs="i",
     xlim = c(0, 40),
     ylim = c(0, 1),
     axes = F)
# to revise the ticks label
axis(1, at=seq(0, 40), labels = F) 
text(x=xtick,  par("usr")[3], 
     labels = xtick, pos = 1, xpd = TRUE)
axis(2, seq(0, 1, 0.05), labels=F)
text(par("usr")[1], ytick,  
     labels = ytick, pos = 2, xpd = TRUE)

# I thinks there must be a better soultion instead of depict each line and points
lines(dta.prob.m$Var1[dta.prob.m$group == "10-2"], 
      dta.prob.m$Freq[dta.prob.m$group == "10-2"], type = "l", pch = 1) 
lines(dta.prob.m$Var1[dta.prob.m$group == "15-2"], 
      dta.prob.m$Freq[dta.prob.m$group == "15-2"], type = "l", pch = 1) 
lines(dta.prob.m$Var1[dta.prob.m$group == "20-1"], 
      dta.prob.m$Freq[dta.prob.m$group == "20-1"], type = "l", pch = 1)
lines(dta.prob.m$Var1[dta.prob.m$group == "20-2"], 
      dta.prob.m$Freq[dta.prob.m$group == "20-2"], type = "l", pch = 1)
lines(dta.prob.m$Var1[dta.prob.m$group == "30-1"], 
      dta.prob.m$Freq[dta.prob.m$group == "30-1"], type = "l", pch = 1)
lines(dta.prob.m$Var1[dta.prob.m$group == "40-1"], 
      dta.prob.m$Freq[dta.prob.m$group == "40-1"], type = "l", pch = 1)
points(dta.prob.m$Var1[dta.prob.m$group == "10-2"], 
      dta.prob.m$Freq[dta.prob.m$group == "10-2"], pch = 19) 
points(dta.prob.m$Var1[dta.prob.m$group == "15-2"], 
       dta.prob.m$Freq[dta.prob.m$group == "15-2"], pch = 1) 
points(dta.prob.m$Var1[dta.prob.m$group == "20-1"], 
       dta.prob.m$Freq[dta.prob.m$group == "20-1"], pch = 1) 
points(dta.prob.m$Var1[dta.prob.m$group == "20-2"], 
       dta.prob.m$Freq[dta.prob.m$group == "20-2"], pch = 19)
points(dta.prob.m$Var1[dta.prob.m$group == "30-1"], 
       dta.prob.m$Freq[dta.prob.m$group == "30-1"], pch = 1) 
points(dta.prob.m$Var1[dta.prob.m$group == "40-1"], 
       dta.prob.m$Freq[dta.prob.m$group == "40-1"], pch = 19)

# not sure if there is any function to do this faster
text(5, 0.85, "10-2")
     lines(c(8.2, 6), c(0.7, 0.85))
text(14, 0.5, "15-2")
     lines(c(12, 13), c(0.56, 0.5))
text(11, 0.4, "20-2")
      lines(c(14, 12), c(0.3, 0.4))
text(18, 0.25, "20-1")
      lines(c(16, 17), c(0.3, 0.25))
text(25, 0.65, "30-1")
      lines(c(28, 26), c(0.55, 0.65))
text(36, 0.65, "40-1")
      lines(c(38.5, 37), c(0.6, 0.65))   
      
# label
mtext("PROBABILITY OF RECALL", side=2, outer=TRUE, line=0 )
mtext("SERIAL POSITION", side=1, outer=TRUE, line=0 )