Closed rafapereirabr closed 2 years ago
this can be done simply by replacing lapply with pbapply::pblapply. I'm not sure this is stricly necessary, and it adds a another package dependency.
lapply
pbapply::pblapply
dt_list <- lapply( X=all_months, FUN= function(i, type.=type, showProgress.=showProgress, select.=select) { # i = all_months[3] # prepare address of online data split_date(i) file_url <- get_url(type, year, month) # download and read data temp_dt <- download_flights_data(file_url, showProgress = showProgress, select = select) # check if download failed if (is.null(temp_dt)) { return(invisible(NULL)) } return(temp_dt) } )
if( showProgress==FALSE){ pbapply::pboptions(type='none') } if( showProgress==TRUE){ pbapply::pboptions(type='txt') } dt_list <- pbapply::pblapply( X=all_months, FUN= function(i, type.=type, showProgress.=FALSE, select.=select) { # i = all_months[3] # prepare address of online data split_date(i) file_url <- get_url(type, year, month) # download and read data temp_dt <- download_flights_data(file_url, showProgress = FALSE, select = select) # check if download failed if (is.null(temp_dt)) { return(invisible(NULL)) } return(temp_dt) } )
this can be done simply by replacing
lapply
withpbapply::pblapply
. I'm not sure this is stricly necessary, and it adds a another package dependency.original
proposed