On this awesome forum I saw a post which shows how to convert a string to a variable and assign a data frame to that variable. For example:
x = “thisisthestring”
# df is a data frame
assign(x, df) # This will assign data frame df to variable thisisthestring
What I want to do is save this data frame with the name thisisthestring. However, if I try
assign(x, df)
save(x, file='somefilename.rda')
the file just contains a string “thisisthestring” and not the data frame df.
I also tried
save(assign(x, df), file = 'somefile.rda'))
That does not work either. Any suggestions how I can save the data frame to a file, where the name of the data frame is specified by the string.
Add
xto thelistargument fromsave(). From the help file: