This is related to an old question: R: How do I list a family of datasets and then rbind them?
I'm working on a new function for the OEC package (https://cran.r-project.org/web/packages/oec/index.html) so I can batch download data.
Here's my new function that I want to include in my package https://gist.github.com/pachamaltese/3b585dded0a80c031c65e98b268ebcc7
So, this is a MWE
#install.packages("devtools")
library(devtools)
install_github("pachamaltese/oec/cran")
library(oec)
getdata_interval("chl","chn",2010,2014,6,2)
How can I assign the dataframes I obtain with this to a list? The problem is not how to do the rbind
. There's an option of using rbindlist
, but before doing that I need to be able to put the dataframes in the list before I can move forward. I did this:
Lines 16-17 (in my gist) are working ok
envir = as.environment(1) assign("getdata_interval_list", replicate(length(years), 0, FALSE), envir = envir)
Then lines 167-168 (in my gist)
envir = as.environment(1) assign(paste(origin, destination, years[[t]], "4char", sep = "_"), origin_destination_year_6char, envir = envir)
do work too.
Then I want to add this line
assign(getdata_interval_list[[t]], parse(paste(origin, destination, years[[t]], "4char", sep = "_")), envir = envir)
and it says
cannot open file 'XXX': No such file or directory
and I want to use that line to putdo.call("rbind", getdata_interval_list)
in the function and then give the user a dataset that has all the information and the pieces of information too.
The tricky thing is that I need both the joined datasets and the individual datasets on the globalenv so that users have access to it.