Skip to content

Commit

Permalink
bug fix (#17) and other small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
btskinner committed Mar 25, 2024
1 parent 038840f commit f3fd489
Show file tree
Hide file tree
Showing 55 changed files with 1,375 additions and 1,379 deletions.
16 changes: 8 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: rscorecard
Title: A Method to Download Department of Education College Scorecard Data
Version: 0.27.0
Version: 0.28.0
Authors@R: person("Benjamin", "Skinner",
email = "btskinner@coe.ufl.edu",
email = "bskinner@neh.gov",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-0337-7415"))
Maintainer: Benjamin Skinner <btskinner@coe.ufl.edu>
Maintainer: Benjamin Skinner <bskinner@neh.gov>
URL: https://github.com/btskinner/rscorecard
BugReports: https://github.com/btskinner/rscorecard/issues
Description: A method to download Department of Education College
Expand All @@ -15,19 +15,19 @@ Description: A method to download Department of Education College
single chained function call. An API key from the U.S. Department of
Education is required.
Depends:
R (>= 3.2.3)
R (>= 4.1.0)
License: MIT + file LICENSE
LazyData: true
Imports: dplyr,
httr,
jsonlite,
lazyeval,
magrittr,
tibble,
tidyselect,
tidyr,
purrr
RoxygenNote: 7.3.0
RoxygenNote: 7.3.1
Encoding: UTF-8
Suggests: knitr,
rmarkdown,
testthat,
tidyselect
testthat
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(sc_dict)
export(sc_filter)
export(sc_filter_)
Expand All @@ -15,4 +14,3 @@ importFrom(httr,GET)
importFrom(httr,content)
importFrom(jsonlite,fromJSON)
importFrom(lazyeval,interp)
importFrom(magrittr,"%>%")
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# v0.28.0

- update to fix error #17
- converted single quotes to double throughout
- converted old magrittr pipe to new base R pipe
- now require at least R version 4.1 (current version is 4.3.3)

# v0.27.0

- update dictionary for 10 October 2023 release of date

# v0.26.0

- update dictionary for 25 April 2023 release of data
Expand Down
46 changes: 23 additions & 23 deletions R/api_convert.R
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@

api_convert <- function(filters) {
## convert rhs
filters[3] <- ifelse(exists(gsub('(^.+)\\[.*\\]$', '\\1',
deparse(filters[[3]])),
envir = globalenv()) == TRUE,
# & sum(grepl(':', filters[[3]], fixed = TRUE)) == 0,
paste(eval(filters[[3]], envir = globalenv()),
collapse = ','),
filters[3])
filters[3] <- gsub('c\\((.+)\\)', '\\1', filters[3])
filters[3] <- gsub('\\"|\\\'', '', filters[3])
filters[3] <- gsub(', ', ',', filters[3])
filters[3] <- gsub(' ', '%20', filters[3])
filters[3] <- gsub(':', '..', filters[3])
## convert rhs
filters[3] <- ifelse(exists(gsub("(^.+)\\[.*\\]$", "\\1",
deparse(filters[[3]])),
envir = globalenv()) == TRUE,
# & sum(grepl(":", filters[[3]], fixed = TRUE)) == 0,
paste(eval(filters[[3]], envir = globalenv()),
collapse = ","),
filters[3])
filters[3] <- gsub("c\\((.+)\\)", "\\1", filters[3])
filters[3] <- gsub("\\\"|\\'", "", filters[3])
filters[3] <- gsub(", ", ",", filters[3])
filters[3] <- gsub(" ", "%20", filters[3])
filters[3] <- gsub(":", "..", filters[3])

## convert operator
filters[1] <- as.character(filters[[1]])
filters[1] <- gsub('%in%', '=', filters[1])
filters[1] <- gsub('==', '=', filters[1])
filters[1] <- gsub('!=', '__not=', filters[1])
filters[1] <- ifelse(grepl('..', filters[3], fixed = TRUE),
gsub('=', '__range=', filters[1]),
filters[1])
## convert operator
filters[1] <- as.character(filters[[1]])
filters[1] <- gsub("%in%", "=", filters[1])
filters[1] <- gsub("==", "=", filters[1])
filters[1] <- gsub("!=", "__not=", filters[1])
filters[1] <- ifelse(grepl("..", filters[3], fixed = TRUE),
gsub("=", "__range=", filters[1]),
filters[1])

## paste
filters[[2]] %+% filters[[1]] %+% filters[[3]]
## paste
filters[[2]] %+% filters[[1]] %+% filters[[3]]
}
14 changes: 7 additions & 7 deletions R/api_key.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
#' @export
sc_key <- function(api_key) {

## check key
if (nchar(api_key) != 40 || !is.character(api_key)) {
stop('API key must be character string of length 40', call. = FALSE)
}
## check key
if (nchar(api_key) != 40 || !is.character(api_key)) {
stop("API key must be character string of length 40", call. = FALSE)
}

Sys.setenv(DATAGOV_API_KEY = api_key)
message('DATAGOV_API_KEY environment variable now set. ' %+%
'You may now use sc_get() without specifying a key.')
Sys.setenv(DATAGOV_API_KEY = api_key)
message("DATAGOV_API_KEY environment variable now set. " %+%
"You may now use sc_get() without specifying a key.")
}


Expand Down
Loading

0 comments on commit f3fd489

Please sign in to comment.