On 11-Oct-07 22:11:46, João Fadista wrote: > Dear all, > > I would like to compute hundreds of chisq.test ´s, and for each test > output I would like to extract only the p-values. So my question is: > how can I make this without making it manually?
?chisq.test (under "Value") tells you that one component of the output is p.value so: for(i in (1:100000)){ x <- matrix(sample((1:100),4),nrow=2) print(chisq.test(x)$p.value) } [1] 0.0009193404 [1] 8.822807e-07 [1] 0.005263787 [1] 0.3424672 [1] 5.72495e-07 [1] 5.29765e-05 [1] 0.6812334 [1] 0.0514063 [1] 8.361445e-13 [1] 0.02701781 [remaining output snipped :)] Best wishes, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 11-Oct-07 Time: 23:41:44 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@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.