library(FAOSTAT)
>
> FAOquery.df = data.frame(varName = c("arableLand", "cerealExp", "cerealProd"),
+ domainCode = c("RL", "TP", "QC"),
+ itemCode = c(6621, 1944, 1717),
+ elementCode = c(5110, 5922, 5510),
+ stringsAsFactors = FALSE)
>
> ## Download the data from FAOSTAT
> FAO.lst = with(FAOquery.df,
+ getFAOtoSYB(name = varName, domainCode = domainCode,
+ itemCode = itemCode, elementCode = elementCode,
+ useCHMT = TRUE, outputFormat = "wide"))
----------------------------------------
** FAOSTAT Data Download (3 in Total) **
----------------------------------------
(1): Downloading variable arableLand ... The specified query has no data, consult FAOSTAT
(2): Downloading variable cerealExp ...
NOTE: Multiple China detected in 'Value' sanitization is performed
OK
(3): Downloading variable cerealProd ... The specified query has no data, consult FAOSTAT
Number of variables successfully downloaded: 1 out of 3
> FAO.lst$entity[, "arableLand"] = as.numeric(FAO.lst$entity[, "arableLand"])
Error in `[.data.frame`(FAO.lst$entity, , "arableLand") :
undefined columns selected