[R] save output of print() to txt file

Duncan Murdoch murdoch.duncan at gmail.com
Thu Jan 5 18:48:13 CET 2012


On 12-01-05 12:05 PM, Ana wrote:
> I am looking for other option to write the output of the print command in R

You don't say why you want this or what platform you're working on, so 
it's hard to choose among the many options, but one possibility is to 
run your script using R CMD BATCH or Rscript.

Another is just to copy and paste the results from the console.

Duncan Murdoch

>
> I am using sink() to write the R output to a file. This is similar to
> what I have:
>
>> a=c(1:30)
>> a
>   [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22
> 23 24 25 26 27 28 29 30
>> sink("vectorA.txt");print(a);sink()
>
> I am looking for othe roptions to save the output of the print()
> command to text file, not to save the objects.
>
> Is there any other way of doing this?
>
> Thanks!
>
> ______________________________________________
> 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