[R] Export to .txt

R. Michael Weylandt michael.weylandt at gmail.com
Wed Nov 2 16:40:20 CET 2011

So playing around with it quickly, it seems that print() works with
sink but cat() doesn't unless you put the sink call in the script at
which point it does as you would expect.

Does that help?


On Wed, Nov 2, 2011 at 2:14 AM, stat.kk <stat.kk at gmail.com> wrote:
> Oh, Im sorry. My file isnt a function but script 'script.R' which looks
> something like that:
> cat('Instruction no 1', '\n')
> browser()   # place for fulfilling it
> cat('Instruction no 2', '\n')
> browser()   # place for fulfilling it
> etc.
> I am running it by
> sink(file='output.txt')
> source('script.R')
> sink(NULL)
> but it doesnt work as I would like. I cant see the output also via saving
> workaspace into .Rhistory file. The goal I would like to achieve is the same
> file as via File - Save to file... option - but I work in command line.
> --
> View this message in context: http://r.789695.n4.nabble.com/Export-to-txt-tp3965699p3971924.html
> Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________
> 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