write staff out
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/