I have data frames in a list a
and I want to use a loop to save these as both rda
and write as dta
. I don't get why I get the error message that object data frame cannot be found:
for (f in a) {
for (name in 1:length(filenames)) {
save(as.data.frame(f),file = paste("~/Dropbox/Data_Insert/Panels/",name,end_rda,sep=""))
write.dta(as.data.frame(f),file = paste("~/Dropbox/Data_Insert/Panels/",name,end_dta,sep=""))
}
}
Error in save(as.data.frame(f), file = paste("~/Dropbox/Data_Insert/Panels/", :
object ‘as.data.frame(f)’ not found
So by f
, this would be indexing the data frame in the list? I did as.data.frame(f)
because when I only used f
, I got the message:
The object "dataframe" must have class data.frame
I changed the code to for f in a, but it still returns an error saying that as.data.frame(f) not found.