Reverse Create Data Frame

Is there a way to reverse create a dataframe given a dataframe in your environment?

For instance if I create a data frame inside a shiny app:

dat <- data.frame(a = 1:3, b = 4:6)

And now I want to reverse engineer that data frame using some function ....does that exist?

somefunction(dat)
# would return
# data.frame(a = 1:3, b = 4:6)

One way

dat <- data.frame(a = 1:3, b = 4:6)
dput(dat)
#> structure(list(a = 1:3, b = 4:6), class = "data.frame", row.names = c(NA, 
#> -3L))

Created on 2020-09-28 by the reprex package (v0.3.0.9001)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.