Infelizmente o pacote FAOSTAT foi descontinuado. Veja a mensagem do autor:

NOTE: This package has been orphaned due to the current re-development of the FAOSTAT API and the fact that I no longer work for the organisation and has no access to the updates.

É melhor baixar a tabela inteira do site da FAO e sumarizar manualmente os dados no R - usar o pacote data.table é uma boa ideia para isso.

Saudações,
 -- Thiago V. dos Santos

Postdoctoral Research Fellow
Department of Climate and Space Science and Engineering
University of Michigan


On Sunday, February 25, 2018, 9:58:31 PM EST, Alisson Lucrécio via R-br <r-br@listas.c3sl.ufpr.br> wrote:


Caro Colegas,

Bom dia.

Tentei usar o pacote FAOSTAT para baixar dados da FAO, mas não funcionar. Eu acho que tem um erro no código arableLand ou domainCode.

Vocês saberiam o que eu poderia fazer para resolver esse erro?

Obrigado.

--
Alisson Lucrecio da Costa

--------------------------

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"))
FAO.lst$entity[, "arableLand"] = as.numeric(FAO.lst$entity[, "arableLand"])

--------------------------

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
_______________________________________________
R-br mailing list
R-br@listas.c3sl.ufpr.br
https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forne�a c�digo m�nimo reproduz�vel.