R/xfaostat_helper_funcs.R
FAOSTAT_metadata.Rd
Download and parse the metadata file from the FAOSTAT portal. FAOSTAT_metadata was adapted from the FAOSTAT package.
FAOSTAT_metadata(code = NULL)
FAOSTAT dataset code if filtering specific dataset; NULL by default and return all dataset info
Dataframe including the metadata of FAOSTAT including URL for download, updating date, detailed descriptions, etc.
FAOSTAT_metadata
#> function (code = NULL)
#> {
#> FAOxml <- XML::xmlParse(xml2::read_xml("http://fenixservices.fao.org/faostat/static/bulkdownloads/datasets_E.xml"))
#> metadata <- XML::xmlToDataFrame(FAOxml, stringsAsFactors = FALSE)
#> names(metadata) <- tolower(gsub("\\.", "_", names(metadata)))
#> metadata["CB" == metadata[, "datasetcode"], "filelocation"] <- "https://fenixservices.fao.org/faostat/static/bulkdownloads/CommodityBalances_(non-food)_E_All_Data_(Normalized).zip"
#> if (!is.null(code)) {
#> metadata <- metadata[code == metadata[, "datasetcode"],
#> ]
#> }
#> return(metadata)
#> }
#> <bytecode: 0x00000000482a5998>
#> <environment: namespace:gcamfaostat>