0

I need to provide a data frame for a MWE, result of other complex operations and tons of data not directly related to the point of the question.

In order to make the example simple and lean, is there a way to transform/convert the data frame into a R command that creates it?

In instances, something like:

yadf <- structure(list(x = c(0, 1, 2, 3, 4), 
                       y = c(0, 1, 4, 9, 16)), 
                  .Names = c('x', 'y'), 
                  row.names = c('0', '1', '2', '3', '4'), 
                  class = 'data.frame')
ggplot(yadf, aes(x, y)) + geom_line()
juanmah
  • 1,130
  • 1
  • 14
  • 21

1 Answers1

0

As @docendo-discimus pointed, dput is the command than convert the data frame into a R command:

> dput(yadf)
structure(list(x = c(0, 1, 2, 3, 4), y = c(0, 1, 4, 9, 16)), .Names = c("x", 
"y"), row.names = c("0", "1", "2", "3", "4"), class = "data.frame")
juanmah
  • 1,130
  • 1
  • 14
  • 21