alkfos<-read.csv("alkfos.csv") alkfos.pctchange<-(sweep(alkfos[-1],1,alkfos$c0,"/")-1)*100 available<-aggregate(!is.na(alkfos[-1]),list(alkfos$grp),sum) means<-aggregate(alkfos.pctchange,list(alkfos$grp),mean,na.rm=T) sds<-aggregate(alkfos.pctchange,list(alkfos$grp),sd,na.rm=T) available<-as.matrix(available[-1]) means<-as.matrix(means[-1]) sds<-as.matrix(sds[-1]) sems<-sds/sqrt(available) times<-c(0,3,6,9,12,18,24)