[R] running a .r script and saving the output to a file

David Winsemius dwinsemius at comcast.net
Thu Apr 9 21:00:35 CEST 2009


On Apr 9, 2009, at 2:21 PM, Gagan Pabla wrote:

> I  first I saved the following commands in a whatever.r file.
>
> data<-read.csv(file="whatever.csv", head=TRUE, sep=",")

#this is where you put the first sink:
> sink("comm.docx")   # but it is not going to be in .docx format, but  
> in text format.
>
> summary(data$SQFT)
> hist(data$STAMP)
> hist(data$STAMP, col='blue')
> hist(data$SHIP, col='blue')
>
# to get back output to the console, you close the "sunken" output file.
sink()

None of this will get you histograms, however. Sink does not deal with  
those. For that you need Sweave or odfWeave.

-- 
David Winsemius
> then I clicked File Menu-> source and chose  whatever.r, it runs the
> commands and produces the histograms and stuff.
> then I did
> sink("comm.docx")
> sink()
>
> It creates an empty file "comm.docx". Now my problem is that I want  
> to run
> the commands in whatever.r file( this part is working )  and then  
> save the
> output(has graphs hists etc) in a file.
>
> How do I do that ? Your help will be greatly appreciated!!
>
> Gagan
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list