Hello R experts, I have generated a data set below. I tried to export the object - my.pvalues (class is "by")
as .txt (or excel file), so the output in matrix form line up nicely in .xls file. Do I have to convert to some other data formats before using write.table? I am having difficulty to get this out. I really appreciate it if anyone here could kindly guide me. Kevin ##### Data #### a <- c(rnorm(6,mean=0.5,sd=0.1),rnorm(18,mean=4,sd=1)) b <- factor(rep(LETTERS[1:4], each=3, lenth=24)) grp <- rep(factor(c("WT","TG")), each=12) d <- as.data.frame(cbind(a,b,grp)) my.pvalues <-by(d, INDICES=d[,"grp"], { FUN=function(x) pairwise.t.test(x$a,x$b)$p.value } ) class(my.pvalues) [1] "by" ### Results ### > my.pvalues d[, "grp"]: 1 1 2 3 2 1 NA NA 3 1 1 NA 4 1 1 1 ------------------------------------------------------------ d[, "grp"]: 2 1 2 3 2 0.7629610481 NA NA 3 0.0006906049 0.0006059707 NA 4 0.0164179404 0.0141134949 0.03267941 [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org 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.