rdinter / usdarnass

An alternative for downloading various USDA data from Quick Stats through R.
GNU General Public License v3.0
10 stars 1 forks source link

Years do not accept ranges from greater than and less than conditionals #3

Open rdinter opened 5 years ago

rdinter commented 5 years ago

Appears to be an API issue when more than one conditional year value is passed through as an argument that only the first (alphabetical) conditional is taken. Expected return on a call with year > 2012 and year < 2016 would be 3 values, but the call returns 7 values.

library(usdarnass)
all_vals <- nass_data(agg_level_desc = "NATIONAL",
                      reference_period_desc = "YEAR",
                      short_desc = "CORN - ACRES PLANTED")
nrow(all_vals)
#> [1] 94

gt_2012 <- nass_data(agg_level_desc = "NATIONAL",
                             reference_period_desc = "YEAR",
                             short_desc = "CORN - ACRES PLANTED",
                             year = ">2012")
nrow(gt_2012)
#> [1] 7

lt_2016 <- nass_data(agg_level_desc = "NATIONAL",
                     reference_period_desc = "YEAR",
                     short_desc = "CORN - ACRES PLANTED",
                     year = "<2016")
nrow(lt_2016)
#> [1] 90

x <- nass_data(agg_level_desc = "NATIONAL",
             reference_period_desc = "YEAR",
             short_desc = "CORN - ACRES PLANTED",
             year = c(">2012", "<2016"))
nrow(x)
#> [1] 7

y <- nass_data(agg_level_desc = "NATIONAL",
             reference_period_desc = "YEAR",
             short_desc = "CORN - ACRES PLANTED",
             year = c("<2016", ">2012"))
nrow(y)
#> [1] 7

z <- nass_data(agg_level_desc = "NATIONAL",
               reference_period_desc = "YEAR",
               short_desc = "CORN - ACRES PLANTED",
               year = c(2013, 2014, 2015))
nrow(z)
#> [1] 3

Created on 2019-07-02 by the reprex package (v0.3.0)