Skip to content

Commit

Permalink
Update to \donttest & cache messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonma committed Nov 16, 2023
1 parent 46947f5 commit 2c01032
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
13 changes: 7 additions & 6 deletions R/lehdr.R
Expand Up @@ -50,7 +50,7 @@
#' @importFrom stringr str_sub str_extract
#'
#' @examples
#' \dontrun{
#' \donttest{
#' # download and load 2014 block level O-D data for Oregon
#' blk_df_or_od <- grab_lodes(state = 'or', year = 2014, lodes_type = "od", job_type = "JT01",
#' segment = "SA01", state_part = "main")
Expand Down Expand Up @@ -161,23 +161,24 @@ grab_lodes <- function(state, year,
if(use_cache) { # User set use_cache to TRUE
# If there is a cache, use it
if(file.exists(fil)) {
message(glue::glue("Cached version of file found in {fil}\n Reading now..."))
message(glue::glue("Cached version of file found in: {fil}"))
} else {
message(glue::glue("Downloading {url} to {fil} now..."))
message(glue::glue("Downloading {url} to cache folder: {fil}"))
res <- httr::GET(url, httr::write_disk(fil))
message(glue::glue("Download complete."))
}
} else { # User did not allow cache to be used
if(file.exists(fil)) {
# Existing file found, inform user of use_cache
message(glue::glue("Cached version of file found in {fil}."))
message(glue::glue("Cached version of file found in: {fil}"))
message(glue::glue("Consider setting use_cache=TRUE to use previously downloaded files."))
message(glue::glue("Overwriting {url} to {fil} now..."))
} else {
# No file found, inform user that we're downloading
message(glue::glue("Downloading {url} to {fil} now..."))
}
# Download (and overwite if necessary) data from server
message(glue::glue("Overwriting {url} to {fil} now..."))
res <- httr::GET(url, httr::write_disk(fil, overwrite = TRUE))
message(glue::glue("Overwrite complete."))
}

# Read in the data
Expand Down
2 changes: 1 addition & 1 deletion man/grab_lodes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion vignettes/getting_started.Rmd
Expand Up @@ -53,7 +53,6 @@ library(stringr)
This first example pulls the Oregon (`state = "or"`) 2020 (`year = 2020`) from LODES version 8 (`version="LODES8"`, default), origin-destination (`lodes_type = "od"`), all jobs including private primary, secondary, and Federal (`job_type = "JT01"`, default), all jobs across ages, earnings, and industry (`segment = "S000"`, default), aggregated at the Census Tract level rather than the default Census Block (`agg_geo = "tract"`).

```{r usage1, eval=FALSE}
or_od <- grab_lodes(state = "or",
year = 2020,
version = "LODES8",
Expand Down

0 comments on commit 2c01032

Please sign in to comment.