Hi Andres,
Thank your for your response. I am very new to R so I am kinda in a black tunnel with this task. Trying to get the: commo_to_items = {
"SOYBEANS": ["SOYBEANS - YIELD, MEASURED IN BU / ACRE", "SOYBEANS - ACRES PLANTED", "SOYBEANS - ACRES HARVESTED", "SOYBEANS - PRODUCTION, MEASURED IN BU"],
}
I built this code, however, its not working:
proc_download <- function(s, c) {
cat(paste(s, c, "\n"))
tryCatch({
data_url <- paste0(
"http://quickstats.nass.usda.gov/api/api_GET/?key=my_API_KEY",
"&key": api_key,
"&source_desc": "SURVEY",
"&commodity_desc": commo,
"&year": year,
"&short_desc": items,
"&agg_level_desc": "NATIONAL",
"&format": "JSON"
)
my_file <- paste0(s, "_", c, "_prices.csv")
download.file(data_url, destfile=my_file)
Sys.sleep(1)
df <- read.csv(my_file)
return(df)
}, error = function(e) {
print(e)
return(NA)
})
}