Re: [R] aggregate output to data frame

2019-03-29 Thread jim holtman
You can also use 'dplyr' library(tidyverse) result <- pcr %>% group_by(Gene, Type, Rep) %>% summarise(mean = mean(Ct), sd = sd(Ct), oth = sd(Ct) / sqrt(sd(Ct)) ) Jim Holtman *Data Munger Guru* *What is the problem that you are trying to solve?Tell me

Re: [R] aggregate output to data frame

2019-03-27 Thread Jim Lemon
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

[R] aggregate output to data frame

2019-03-27 Thread cir p via R-help
Dear users, i am trying to summarize data using "aggregate" with the following command: aggregate(pcr$Ct,c(pcr["Gene"],pcr["Type"],pcr["Rep"]),FUN=function(x){c(mean(x), sd(x), sd(x)/sqrt(sd(x)))}) and the structure of the resulting data frame is 'data.frame':66 obs. of  4 variables: $ Gen