#[0] tapply exercise
x<-c(1,2,3,4,5,6)
y<-c("a","b","a","b","a","b"); z<-c("y","y","y","x","x","x")
xydata<-data.frame(x,y,z, stringsAsFactors = FALSE)
xydata
#[1]--------------------------
tapply(xydata[,1],xydata[,2],sum)
tapply(xydata[,1],xydata[,2],length)
#[2]--------------------------
classdata<-tapply(xydata[,1],xydata[,2],list)
classdata$a; classdata$b
classdata[[1]]; classdata[[2]]
#[3]--------------------------
tapply(xydata[,1],list(xydata[,2],xydata[,3]),list)
index2 <- paste(xydata[,2],xydata[,3],sep=""); index2
xydata$index2 <- index2; xydata
tapply(xydata[,1],xydata$index2,list)
#[4]--------------------------
tapply(xydata[,1],paste(xydata[,2],xydata[,3],sep=""),list)