I\'m trying to use the R code from this answer to convert a bunch of rdata files to CSV.
resave <- function(file){
e <- new.env(parent = emptyenv())
That answer was designed to handle object of class-'data.frame'. You only have an object of class-'list' which happens to have items that are dataframes. So there isn't an object with the name "2" in you workspace but there is an element in the 'dataa'-list that is named "2" and all of the other elements appear to also be dataframes, so why not use:
lapply( names(dataa), function(nam) write.csv( data[[nam]], file=paste0(nam, ".Rdata") ) )
I'll vote for the other answer, but here's some almost working code:
resave <- function(file){
e <- new.env(parent = emptyenv())
load(file, envir = e)
obj <- get('dataa', envir =e)
lapply( names(obj), function(nam) {
write.csv( obj[[nam]], file=paste(nam, ".csv", sep="") )
cat(sprintf('%s.csv
', nam) )
}
)
}
resave("indiv8-hmmprob.RData")
Here's the output. which works but it's throwing in some wierd printed stuff at the end, the [[1]] NULL, etc.
2.csv
3.csv
4.csv
X.csv
[[1]]
NULL
[[2]]
NULL
[[3]]
NULL
[[4]]
NULL