Open timriffe opened 2 years ago
This is a very helpful note. For example, to get all process types for a country we could do:
#' get all data process types for location x
get.by.location <- function(x){
get.all.types <- function(type0){
res0 <- tryCatch(
{
get_recorddata(
dataProcessTypeIds = type0,
startYear = 1920,
endYear = 2030,
indicatorIds = c(239, 229, 234, 221),
locIds = x,
locAreaTypeIds = 2, ## "Whole area"
subGroupIds = 2, ## "Total or All groups"
includeUncertainty = TRUE)
}, error = function(cond) return(NULL)
)
return(res0)
}
return(rbindlist(lapply(0:15, get.all.types)))
}
A feature, not to be implemented before summer 2022: if a record is requested and not available you get a 404 error. Let's trap that error and return it as a message, and make the function return
NULL
. Can't do this change now because it's used in production at the moment @cimentadaj