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. Thank you Sebastien // [[alternative HTML version deleted]]
Prof Brian Ripley
2014-Aug-05 17:40 UTC
[R] Equivalent of read.table for object rather than file
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 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. >PLEASE do. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
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? 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 posting guidehttp://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 [[alternative HTML version deleted]]