Is there a way in R to take a dataframe and auto-generate lines of code that would, if run, create that same dataframe from scratch?
So if my starting point is a dataframe df:
field_1 field_2
————————————————-
1 A
2 B
3 C
I’d like some way to generate code automatically to recreate the data, eg:
df <- data.frame(field_1 = c(1, 2, 3), field_2 = c(“A”, “B”, “C”))
In my case these dataframes would always be small - max about 50 rows and 3-4 columns.
Thank you.