does sink() do what you want?
see ?sink for more > #divert printed results to file > sink(file = output.txt) > #commands here > chisq.test(x,p=probs) > #turn off sink > sink(file = NULL) If you are not typing the commands at the prompt but are using an external editor or text file for your commands via source() then you need to wrap chisq.test(x,p=probs) in print() eg: print(chisq.test(x,p=probs)) Hope this helps Gavin %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [T] +44 (0)20 7679 5522 ENSIS Research Fellow [F] +44 (0)20 7679 7565 ENSIS Ltd. & ECRC [E] [EMAIL PROTECTED] UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/ 26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/ London. WC1H 0AP. %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 25 March 2003 23:59 To: r-help Subject: [R] How to write the output of a function into a file? I cannot find the solutions in the mannual about "import and export of data". For example, I run >chisq.test(x,p=probs) chi-squared..... ......... How can I write the output into a file? Is there some file operations in R? Actually, I only want to save the P-value. But I don't know how I can extract the P-value field only from the output of chisq.test. So, I think I would better save all the output. I tried cat/write....They cannot do this. Thanks in advance. [[alternate HTML version deleted]] ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
