I am new to R and loops. I have a data frame (xyz). I am running a loop and want to save a new new data frames under different names.
states <- c("AL", "AK")
keywords <- c("snow", "rain")
filepath <- file.path("C:/data/")
for(state_var in states)
for(key_var in keywords)
{
save(xyz, file = (file.path(filepath, paste0(state_var, sep = "_", key_var,".RData"))))
}
Everything is working perfectly and new data frame is saved under different names. But when I load saved data frames all data frames have exactly same name xyz.
How it is possible to save under different df name. Thanks a lot.
load(file.path(filepath, "AL_snow.RData"))