Skip to content
Prev 379089 / 398502 Next

aggregate output to data frame

Hi Cyrus,
Try this:

pcr<-data.frame(Ct=runif(66,10,20),Gene=rep(LETTERS[1:22],3),
 Type=rep(c("Std","Unkn"),33),Rep=rep(1:3,each=22))
testagg<-aggregate(pcr$Ct,c(pcr["Gene"],pcr["Type"],pcr["Rep"]),
 FUN=function(x){c(mean(x), sd(x), sd(x)/sqrt(sd(x)))})
nxcol<-dim(testagg$x)[2]
newxs<-paste("x",1:nxcol,sep="")
for(col in 1:nxcol)
 testagg[[newxs[col]]]<-testagg$x[,col]
testagg$x<-NULL

Jim
On Thu, Mar 28, 2019 at 12:39 PM cir p via R-help <r-help at r-project.org> wrote: