[R] Message for R-help mailing list

Uwe Ligges ligges at statistik.tu-dortmund.de
Wed Jul 27 19:42:51 CEST 2011



On 27.07.2011 02:17, Jeremy Miles wrote:
> This is clearly a message for the R-help mailing list, since it was
> sent to the R help mailing list.
>
>   fisher.test(x)[1]

Since the test object is actually a list, your probably want

fisher.test(x)[[1]]
or more obvious
fisher.test(x)[["p.value"]]

Uwe Ligges


>
> Jeremy
>
>
>
>
> On 26 July 2011 14:51, Zmarz, Pawel<pawel.zmarz05 at imperial.ac.uk>  wrote:
>> Dear r-helpers,
>>
>> I would be very grateful if you could post the message below on the r-help discussion board. Thank you very much!
>>
>> Best Wishes,
>> Pawel
>>
>>
>> Hello R community,
>>
>> I am generating lots of results using the fisher.test function, testing many 2x2 tables of SNPs for association with a particular phenotype.
>>
>> A typical output of the fisher.test function would be (for example):
>>
>> data:  data1
>> p-value = 0.9837
>> alternative hypothesis: true odds ratio is greater than 1
>> 95 percent confidence interval:
>>   0.4162551       Inf
>> sample estimates:
>> odds ratio
>>   0.6262607
>>
>> That's lovely, but my problem is that I am only interested in the "p-value" result for each SNP that I check. If it is possible, I would like to extract all the p-values I generate (I use a loop to generate all of them), chuck them into a matrix, and then into a text file. Or perhaps directly export them into a text file, without using a matrix -- whatever is easier. However, I am stuck on how to do this...
>>
>> Maybe one way would be to save the full results (as they are above) into a text file and then get R to read just the specific part of the file (i.e. the p-value part) and then build a matrix...but I do not know what the code would be for the "specific reading" part..?
>>
>> Would anyone have any ideas??
>>
>> Thank you so much for your help!!!
>>
>> Best Wishes,
>> Pawel
>>
>>         [[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.



More information about the R-help mailing list