Hello everyone,
Peter (see my earlier post) recommended the following script for finding the
means and standard deviations and putting them in table form.
However, I would like the standard deviations under the means in brackets.
Can anyone check this code to see how this can be adjusted?
library(xtable)
dataset1 = matrix( c(1,2,3,4, 5, 6 ), 2 , 3)
dataset2 = matrix( c(4,3,5,10, 1, 0), 2, 3)
dataset <- rbind(dataset1,dataset2) #combine dataset
means <- apply(dataset,1,mean) #calculate row means
sds <- apply(dataset,1,sd) #calculate row standard deviation
msd <- paste(round(means,2)," (",round(sds,2),")",sep="") #mean and
standard deviation
rn <- c("Var1","Var2") #rownames
cn <- c("Dataset1","Dataset2") #column names
tab <- matrix(msd,2,2,dimnames=list(rn,cn))
tab
Dataset1 Dataset2
Var1 "3 (2)" "3.33 (2.08)"
Var2 "4 (2)" "4.33 (5.13)"
xtable(tab)
--
Thanks,
Jim.
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.