[R] Equivalent of read.table for object rather than file

sbihorel Sebastien.Bihorel at cognigencorp.com
Wed Aug 6 16:09:41 CEST 2014


For some reason, I did not receive your replies on my email client and had to copy-paste the content of the thread
directly from the R archive website. Thank you for pointing out the text connection solution.

Regarding the posting guide, I read it 6-7 years ago when I joined the mailing list and must admit that I did not
read it since. Never had any issues in the past sending post in plain text or HTML format. That being said, I
will be careful about this in the future.

Thank you for your help.


On 05/08/2014 19:15, sbihorel wrote:
>/  Hi,
/>/  Thanks for the info. Unfortunately, read.table() does not have the text argument in the version of R that I can use.
/>/  Do you know when was this argument introduced?
No, but the posting guide asked you to update *before posting* (have you
yet read it?: you still sent HTML when asked not to).

In any case, the help text tells you how to do it: use a text connection.

/>/  Sebastien
/>/  On 05/08/2014 18:29, sbihorel wrote:
/>>/  /  Hi,
/>/  />/
/>/  />/  Let's say that I have a scalar character object called tmp which stores
/>/  />/  the entire content of an ASCII file. Is there a function that would
/>/  />/  process tmp the same way read.table() would process the content of the
/>/  />/  original ASCII file?
/>/  />/
/>/  />/  The content of tmp will come from a database, and I want to extract the
/>/  />/  data without writing and reading to disk or without asking the database
/>/  />/  to transform the file content into a table.
/>/  /
/>/  The equivalent is read.table.  See its 'text' argument:
/>/         text: character string: if 'file' is not supplied and this is, then
/>/               data are read from the value of 'text' via a text connection.
/>/               Notice that a literal string can be used to include (small)
/>/               data sets within R code.
/>>/  /
/>/  />/  Thank you
/>/  />/
/>/  />/  Sebastien
/>/  />/  //
/>/  />/
/>/  />/  	[[alternative HTML version deleted]]
/>/  />/
/>/  />/  ______________________________________________
/>/  />/  R-help at r-project.org  <https://stat.ethz.ch/mailman/listinfo/r-help>  mailing list
/>/  />/https://stat.ethz.ch/mailman/listinfo/r-help
/>/  />/  PLEASE do read the postingguidehttp://www.R-project.org/posting-guide.html
/>/  />/  and provide commented, minimal, self-contained, reproducible code.
/>/  />/
/>/  /PLEASE do.

Brian D. Ripley,ripley at stats.ox.ac.uk  <https://stat.ethz.ch/mailman/listinfo/r-help>
Professor of Applied Statistics,http://www.stats.ox.ac.uk/~ripley/  <http://www.stats.ox.ac.uk/%7Eripley/>
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list