Dear All I am a new user to R and so I have a question which I hope you can help me with. I am running simulations calculating correlation coefficients from bivariate data and I was wondering whether there is a way of exporting 1000 simulation results from R to a text file or to another file for further manipulation. I am having difficulty I think because of the text combined in with the numerical results. Many Thanks Carolyn Marshall
On 07/11/03 09:58, C.E.Marshall wrote:>I am running simulations calculating correlation coefficients from bivariate >data and I was wondering whether there is a way of exporting 1000 simulation >results from R to a text file or to another file for further manipulation. I >am having difficulty I think because of the text combined in with the >numerical results.If I understand you, it would seem that the trick is to put the results of your simulation into a matrix or data frame, possibly with one row or column per result. I assume that each result consists of a few numbers, each representing some variable. Then use write.table, write.matrix, or write. -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron R page: http://finzi.psych.upenn.edu/
Do you want "write(..., append=TRUE)"? If not, please provide a toy problem that shows clearly what you thought should work and why it is not satisfactory. You are more likely to get what you want from this list if someone else can pick up your scrap of code and try something in 30 seconds than if it takes them 10 minutes to figure out what you are even asking. Please also include the version of R you are using under which operating system. hope this helps. spencer graves C.E.Marshall wrote:> Dear All > > I am a new user to R and so I have a question which I hope you can help me > with. > > I am running simulations calculating correlation coefficients from bivariate > data and I was wondering whether there is a way of exporting 1000 simulation > results from R to a text file or to another file for further manipulation. I > am having difficulty I think because of the text combined in with the > numerical results. > > Many Thanks > > Carolyn Marshall > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
This really depends on what your output is. As previously suggested save() and write() are excellent suggestions. for(ii in 1:1000){ out <- cor( x[ii, ], y[ii, ] ) # or whatever cat(ii, "\t", out, "\n", append=TRUE, file="output.txt") } This method is really not worth it for small simulations but I found this to be extremely useful with large simulations. The output file can act both as log/progress report file and provide partial results even if your program crashes. More sophisticated method can be found under connections(). -----Original Message----- From: C.E.Marshall [mailto:C.E.Marshall at newcastle.ac.uk] Sent: Friday, July 11, 2003 4:59 PM To: r-help at stat.math.ethz.ch Subject: [R] Exporting data Dear All I am a new user to R and so I have a question which I hope you can help me with. I am running simulations calculating correlation coefficients from bivariate data and I was wondering whether there is a way of exporting 1000 simulation results from R to a text file or to another file for further manipulation. I am having difficulty I think because of the text combined in with the numerical results. Many Thanks Carolyn Marshall ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help