Hello, Is there any simple command to write the data.frame to the file in the format of command line input? For example, I read a table as > data <- read.table() and want to write out the 'data' object into my R file as data <- data.frame( some.column1=c( 1, 2 ), some.column2=c( 1, 2 ) row.names=c("row name1", "row name2" ) so I don't have to type the data again in my library file to provide demos. Thank you, in advance. ------------ Wataru Shito -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Wataru Shito wrote:> > Hello, > > Is there any simple command to write the data.frame to the file in the > format of command line input? > > For example, I read a table as > > > data <- read.table() > > and want to write out the 'data' object into my R file as > > data <- data.frame( some.column1=c( 1, 2 ), > some.column2=c( 1, 2 ) > row.names=c("row name1", "row name2" ) > > so I don't have to type the data again in my library file to provide > demos.The recommended way to make data available is to use the data() construct. If you want to avoid it, you can assign the data.frame to a variable name (the name "data" isn't a good idea, because data() is already a function) as you described above, e.g. put it in a file "zzz.R". This is described exactly in the manual "Writing R Extensions" in chapter 1, particularly see section 1.1.3. Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 10 May 2002, Wataru Shito wrote:> Hello, > > Is there any simple command to write the data.frame to the file in the > format of command line input? > > For example, I read a table as > > > data <- read.table() > > and want to write out the 'data' object into my R file as > > data <- data.frame( some.column1=c( 1, 2 ), > some.column2=c( 1, 2 ) > row.names=c("row name1", "row name2" ) > > so I don't have to type the data again in my library file to provide > demos.The dump() and dput() commands do this. You could also use save() to save an R binary file -- these are compatible across platforms and are compressed to take up less space than dump()s. -thomas -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._