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)))
#> 
#>   # Bug fix for CB; can remove later if FAOSTAT update the link later
#>   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: 0x0000000042a70840>
#> <environment: namespace:gcamfaostat>