Hi there, I need to output t.test result from R into regular text file, anyone has a suggestion what kind of function to use in what format? thanks a lot. Zeren Gao
On 05/27/03 16:01, ZRG (Zeren Gao) wrote:>Hi there, >I need to output t.test result from R into regular text file, anyone has a >suggestion what kind of function to use in what format? >thanks a lot.The following function prints a t test result in LaTeX format, in a way that elicits the fewest complaints from reviewers for psychology journals. This is for a one-sample test. ttest <- function (x) { tc <- t.test(x) print(paste("($t_{",tc[[2]],"}=",formatC(tc[[1]],format="f",digits=2), "$, $p=",formatC(tc[[3]],format="f"),"$)",sep=""),quote=FALSE) print(tc$estimate) } I don't know how you want to represent degrees of freedom in "regular text," but you can probably figure out how to modify this. -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron R page: http://finzi.psych.upenn.edu/
Have you considered "sink"? hth. spencer graves ZRG (Zeren Gao) wrote:> Hi there, > I need to output t.test result from R into regular text file, anyone has a suggestion what kind of function to use in what format? > thanks a lot. > Zeren Gao > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
On 27 May 2003 at 16:01, ZRG (Zeren Gao) wrote: Maybe capture.output is what you need, new in R-1.7.0 an example: capture.output( t.test( rnorm(10), rnorm(10, 2) ) ) [1] "" [2] " Welch Two Sample t-test" [3] "" [4] "data: rnorm(10) and rnorm(10, 2) " [5] "t = -5.5629, df = 16.133, p-value = 4.157e-05" [6] "alternative hypothesis: true difference in means is not equal to 0 " [7] "95 percent confidence interval:" [8] " -2.897467 -1.299261 " [9] "sample estimates:" [10] " mean of x mean of y " [11] "-0.1485742 1.9497894 " [12] "" This also has a file= argument. Kjetil Halvorsen> Hi there, > I need to output t.test result from R into regular text file, anyone has a suggestion what kind of function to use in what format? > thanks a lot. > Zeren Gao > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help