[R] R equivalent of Python str()?
William Dunlap
wdunlap at tibco.com
Wed Feb 8 05:22:14 CET 2012
Use
capture.output(print(yourData))
to capture would be printed by print as a vector
of a strings (one per line of printout). Paste
together if desired.
Use deparse(yourData) to get a string representation
that can be parsed by R (useful for sending to others
who are using R).
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Ernest Adrogué
> Sent: Tuesday, February 07, 2012 4:09 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] R equivalent of Python str()?
>
> Hi,
>
> I was wondering if there's a function in R that is meant to return a
> string representation of an object. Basically, it's like print() but
> it doesn't print anything, it only returns a string.
>
> I know there's a str() function but it's not quite the same. I mean a
> function that returns the same string that print() would display.
>
> --
> Bye,
> Ernest
>
> ______________________________________________
> 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