print() to file?

View: New views
3 Messages — Rating Filter:   Alert me  

print() to file?

by Steve Jaffe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'd like to write some objects (eg arrays) to a log file. cat() flattens them out. I'd like them formatted as in 'print' but print only writes to stdout. Is there a simple way to achieve this result?

Thanks

Re: print() to file?

by Greg Snow-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

?sink

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow@...
801.408.8111


> -----Original Message-----
> From: r-help-bounces@... [mailto:r-help-bounces@r-
> project.org] On Behalf Of Steve Jaffe
> Sent: Wednesday, July 08, 2009 1:03 PM
> To: r-help@...
> Subject: [R] print() to file?
>
>
> I'd like to write some objects (eg arrays) to a log file. cat()
> flattens them
> out. I'd like them formatted as in 'print' but print only writes to
> stdout.
> Is there a simple way to achieve this result?
>
> Thanks
>
> --
> View this message in context: http://www.nabble.com/print%28%29-to-
> file--tp24397445p24397445.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@... 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.

______________________________________________
R-help@... 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.

Parent Message unknown Re: print() to file?

by Moshe Olshansky-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


One possibility is to use sink (see ?sink).

--- On Thu, 9/7/09, Steve Jaffe <sjaffe@...> wrote:

> From: Steve Jaffe <sjaffe@...>
> Subject: [R]  print() to file?
> To: r-help@...
> Received: Thursday, 9 July, 2009, 5:03 AM
>
> I'd like to write some objects (eg arrays) to a log file.
> cat() flattens them
> out. I'd like them formatted as in 'print' but print only
> writes to stdout.
> Is there a simple way to achieve this result?
>
> Thanks
>
> --
> View this message in context: http://www.nabble.com/print%28%29-to-file--tp24397445p24397445.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@...
> 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.
>

______________________________________________
R-help@... 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.