[R] another question about fisher.test

Romain François francoisromain at free.fr
Sun Oct 31 11:20:07 CET 2004


Try that :

results <- rep(0,42)
for (i in 1:42) {
# testing difference in income(pinc) between people in
# (with in1=1) and out (with in1=0) of the program for
# group i
   results[i] <- fisher.test(m$pinc[m$group==i], m$in1[m$group==i],
   workspace=40000000, hybrid=F)$p.value
}
results



If you want the results to be saved in a file, take a alook at :
?sink
?write.table
Please read the posting guide, an the introduction to R, you can easily 
learn with those how to save the results of a function to a vector. And 
please post some code that can be run directly in R console.


fang lai a écrit :

>Dear all,
> I have another question about fisher.test:
>Is there any way to save the resulting p-value in a
>matrix or file after a loop as below?
> for (i in 1:42) {
># testing difference in income(pinc) between people in
># (with in1=1) and out (with in1=0) of the program for
># group i
>fisher.test(m$pinc[m$group==i], m$in1[m$group==i],
>workspace=40000000, hybrid=F)}
>
> When I run this loop, there is no results shown on
>the terminal. I wonder if there is a way to store the
>result for each i in a file or matrix.
>Many thanks,
>
>Fang
>
> 
>
>=====
>Lai, Fang
>
>PhD candidate
>University of California, Berkeley
>Department of Agricultural and Resource Economics
>314 Giannini Hall, Berkeley, CA 94720-3310
>tel: (510) 643 - 5421(O)
>     (510) 847 - 9811(Cell)
>fax: (510) 643 - 8911
>email: lai at are.berkeley.edu
>http://www.are.berkeley.edu/jobmarket/fang.html
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
>  
>

-- 
Romain François
25, avenue Guy Moquet
94 400 Vitry sur seine
FRANCE
_______________________
_______________________

francoisromain at free.fr
01 46 80 65 60
06 18 39 14 69




More information about the R-help mailing list