I'm trying to loop through a character vector, and for each value, run a slightly different query. I then want to capture the results, and save them locally as an rdata file. Once that's saved, I can delete the R object.
I know that I should be doing this as an apply/sapply and would appreciate a tip for how to do that...
However, my main issue is that while the rdata files save nicely with the names I'd hoped for (i.e. "TABLE1", "TABLE2"), when I load them back into R, they all have the object name of "thisname", with a single value corresponding to the name I'd hoped for (e.g. "TABLE1"). I have been attempting to make this work for far too long .
If anyone has a suggestion, I'd appreciate it!
tables = c('TABLE1','TABLE2')
for (i in 1:length(tables)){
thisname=paste0(tables[i])
data= sqlQuery(oracle.channel, paste("select * from",table_renamer(tables[i]),"WHERE ROWNUM<10;"))
assign(thisname,data)
save(thisname, file=file.path(paste0( tables[i],".RData")))
rm(thisname)
rm(thisdf)
}