Download and parse the metadata file from the FAOSTAT portal. FAOSTAT_metadata was adapted from the FAOSTAT package.

FAOSTAT_metadata(code = NULL)

Arguments

code

FAOSTAT dataset code if filtering specific dataset; NULL by default and return all dataset info

Value

Dataframe including the metadata of FAOSTAT including URL for download, updating date, detailed descriptions, etc.

Examples

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>