dear R experts---is there a function that prints a data frame to a string?
cat() cannot handle lists, so I cannot write cat("your data frame
is:\n",
df, "\n").
regards, /iaw
----
Ivo Welch (ivo.welch@gmail.com)
[[alternative HTML version deleted]]
What do you mean by prints? You can use capture.output to get what would regularly be printed to the screen into a text vector, or use dput to get a version of an object that could be read back into another R session. On Thu, May 31, 2012 at 2:10 PM, ivo welch <ivo.welch at gmail.com> wrote:> dear R experts---is there a function that prints a data frame to a string? > ?cat() cannot handle lists, so I cannot write cat("your data frame is:\n", > df, "\n"). > > regards, /iaw > ---- > Ivo Welch (ivo.welch at gmail.com) > > ? ? ? ?[[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.-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com
capture.output(print(mydf))
note that df is a base function... best to not use it as a variable.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live
Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
ivo welch <ivo.welch at gmail.com> wrote:
>dear R experts---is there a function that prints a data frame to a
>string?
>cat() cannot handle lists, so I cannot write cat("your data frame
>is:\n",
>df, "\n").
>
>regards, /iaw
>----
>Ivo Welch (ivo.welch at gmail.com)
>
> [[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.