You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
appended to the parameter name to allow for inequalities. It would be nice is users could specify year >= 2012 and have that be translated into year__GE = 2012 in the query.
The text was updated successfully, but these errors were encountered:
# Conditional year values
conditional_years <- function(x) {
# Check to see if year used a logical operator
years <- trimws(x)
punct <- grepl("[[:punct:]]", years)
punct_years <- as.numeric(gsub("[[:punct:]]", "", years))
# Conditional year values
# __LE = <=
# __LT = <
# __GT = >
# __GE = >=
# __LIKE = like
# __NOT_LIKE = not like
# __NE = not equal
year <- punct_years[!punct]
year__LE <- punct_years[(grepl("^=<|^<=", years) | grepl("=>$|>=$", years))]
year__LT <- punct_years[((grepl("^<", years) | grepl(">$", years)) &
!grepl("=", years))]
year__GE <- punct_years[(grepl("^=>|^>=", years) | grepl("=<$|<=$", years))]
year__GT <- punct_years[((grepl("^>", years) | grepl("<$", years)) &
!grepl("=", years))]
results <- list(year = year,
year__LE = year__LE,
year__LT = year__LT,
year__GE = year__GE,
year__GT = year__GT)
return(results)
}
Basically treat the argument for year as a character and search through for punctuation that might be at the beginning or end.
One issue is that the API is finicky if you want to use multiple conditionals to create a range of year values. The API seems to only take the first conditional related to year as the subset rdinter/usdarnass#3
The API uses:
appended to the parameter name to allow for inequalities. It would be nice is users could specify
year >= 2012
and have that be translated intoyear__GE = 2012
in the query.The text was updated successfully, but these errors were encountered: