[R] exporting data.frame

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri May 10 08:44:58 CEST 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 recommended way to make data available is to use the data()
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

More information about the R-help mailing list