[R] How can I export a paired t-test output table to an excel file?

David Winsemius dwinsemius at comcast.net
Sat Jun 2 16:49:17 CEST 2012


On Jun 2, 2012, at 8:58 AM, Nicolas Iderhoff wrote:

> Hello Jason,
> if you put your t-test into an r-object, like here (taken from the  
> documentary example):
>
Would need to attach(airqualty) for that to succeed
> t.test <- pairwise.t.test(Ozone, Month)
Better to use an object name that is not the name of a function.

>
> you can get the table with
>
> t.test$p.value
>
> also you can get a lot of other stuff. you can see what's available  
> with "str(t.test)".
> hope that's what you're looking for!
>
> Am 02.06.2012 um 13:45 schrieb Jason Love:
>
>> Hi R users,
>> Could anyone let me know how to export a paired t-test output table  
>> (see
>> below) to an excel file?

There is a `write.matrix` function in MASS that accepts a 'sep'  
argument. You can use that with "\t" to write a tab-separated file for  
Excel. Copied from the console or the "clipboard file" you should be  
able to paste or import into Excel without needing to use that  
programs fixed format importing dialog.

# named the object t.test.res

write.matrix(t.test.res$p.value, file="ttest.tsv", sep="\t")

-- 
David.

>>
>> Jason,
>>
>>
>>
>>
>> with(score2,pairwise.t.test(values,ind,
>> +         p.adjust.method="holm", paired=T))
>>
>>
>> Pairwise comparisons using paired t tests
>>
>> data:  values and ind
>>
>>               test1     test2    test3     test4     test5     test6
>> test1        1.0000  -       -       -          -       -
>> test2        1.0000  1.0000  -       -          -       -
>> test3        1.0000  1.0000  1.0000  -          -       -
>> test4        0.2110  0.4331  0.3402  0.0780     -       -
>> test5        8.2e-08 1.4e-05 6.7e-05 1.3e-05    3.1e-06 -
>> test6        1.0000  0.4851  1.0000  1.0000     0.0055  1.4e-05
>>
>> 	[[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at 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.
>
> ______________________________________________
> R-help at 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list