I have a data.frame (e.g. read from a data file using read.delim
) that contains the following data:
'data.frame': 10 obs. of 3 variables:
$ x : int 1 2 3 4 5 6 7 8 9 10
$ y1: num 3 5 1 8 2 4 5 0 8 2
$ y2: num 1 8 2 1 4 5 3 0 8 2
I'm now looking for a function in R, which takes the variable (data
) and prints out a possible command that creates a variable like data
. In this case, it should print out:
data <- data.frame(
x=c(1:10)
, y1=c(3,5,1,8,2,4,5,0,8,2)
, y2=c(1,8,2,1,4,5,3,0,8,2)
)
Is there a function like this in R.
In MySQL there exists for example the command SHOW CREATE TABLE tbl_name
, which
Shows the CREATE TABLE statement that creates the named table.
I'm looking for something similar for variables in R.