Mark Na
2009-Jun-17 14:43 UTC
[R] How to translate a dataframe into the R code that makes that dataframe?
Hi, I am helping another R user (off list) and I would like to email her an R script containing the data she needs and the code to solve her problem. I have made a small dummy dataset, but instead of sending her a CSV I would prefer to send the data embedded in the script, so there would be a like in the script like: my.df<-c( etc, etc, etc I have made the dataframe (in a spreadsheet) and imported it into R (using read.csv) and now I wonder if there is a function to produce the code that makes that dataframe. Thanks for any help you can provide. Mark Na
Gabor Grothendieck
2009-Jun-17 14:50 UTC
[R] How to translate a dataframe into the R code that makes that dataframe?
See ?dump ?dput On Wed, Jun 17, 2009 at 10:43 AM, Mark Na<mtb954 at gmail.com> wrote:> Hi, > > I am helping another R user (off list) and I would like to email her > an R script containing the data she needs and the code to solve her > problem. I have made a small dummy dataset, but instead of sending her > a CSV I would prefer to send the data embedded in the script, so there > would be a like in the script like: > > my.df<-c( etc, etc, etc > > I have made the dataframe (in a spreadsheet) and imported it into R > (using read.csv) and now I wonder if there is a function to produce > the code that makes that dataframe. > > Thanks for any help you can provide. > > Mark Na > > ______________________________________________ > 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. >
stephen sefick
2009-Jun-17 14:53 UTC
[R] How to translate a dataframe into the R code that makes that dataframe?
why not save it as an .Rd file, or use some R code to to create the dataframe. This way the code will be totally self-contained. Stephen On Wed, Jun 17, 2009 at 10:43 AM, Mark Na<mtb954 at gmail.com> wrote:> Hi, > > I am helping another R user (off list) and I would like to email her > an R script containing the data she needs and the code to solve her > problem. I have made a small dummy dataset, but instead of sending her > a CSV I would prefer to send the data embedded in the script, so there > would be a like in the script like: > > my.df<-c( etc, etc, etc > > I have made the dataframe (in a spreadsheet) and imported it into R > (using read.csv) and now I wonder if there is a function to produce > the code that makes that dataframe. > > Thanks for any help you can provide. > > Mark Na > > ______________________________________________ > 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. >-- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis