From a4770e98b4b7ba5a597880af8f7ceb8154bfbc16 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 11:03:25 -0400 Subject: [PATCH 01/50] upgrade Roxygen version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 09a390d..adf88d1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -55,5 +55,5 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.0 +RoxygenNote: 7.2.1 Website: https://github.com/Metropolitan-Council/councilR From 6f67efdb6284074273ace8a3097f372600a2a3c4 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 11:06:26 -0400 Subject: [PATCH 02/50] upgrade testthat doc --- tests/testthat.R | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/testthat.R b/tests/testthat.R index 8ece46e..ac56186 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,3 +1,11 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/tests.html +# * https://testthat.r-lib.org/reference/test_package.html#special-files + library(testthat) library(councilR) library(curl) From 711ab481040d03ff37096adbc8633ba2918cd72b Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 11:38:18 -0400 Subject: [PATCH 03/50] remove library(curl) --- tests/testthat.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat.R b/tests/testthat.R index ac56186..e664ca6 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -8,6 +8,5 @@ library(testthat) library(councilR) -library(curl) test_check("councilR") From 7478f58b60178fb99e9cb7ea45814b1baf26849a Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 12:32:30 -0400 Subject: [PATCH 04/50] add testing for colors --- tests/testthat/test-colors.R | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/testthat/test-colors.R diff --git a/tests/testthat/test-colors.R b/tests/testthat/test-colors.R new file mode 100644 index 0000000..226a936 --- /dev/null +++ b/tests/testthat/test-colors.R @@ -0,0 +1,12 @@ +test_that("Council Blue is correct color code", { + + testthat::expect_equal(colors$councilBlue, "#0054A4") + +}) + +test_that("All 29 colors are included", { + + testthat::expect_equal(length(colors), 29L) + +}) + From 21755cb2b410d7c8c1cdcd141c943441e289b5ae Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 12:32:44 -0400 Subject: [PATCH 05/50] update docs --- vignettes/Options.Rmd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vignettes/Options.Rmd b/vignettes/Options.Rmd index f553f16..7b5a243 100644 --- a/vignettes/Options.Rmd +++ b/vignettes/Options.Rmd @@ -27,14 +27,15 @@ options(councilR.uid = "mc\\myuuid", # your user id ) ``` -If you'd like to have these options loaded when you start up R, edit your `.Rprofile`. An easy way to accomplish this is with `usethis::edit_r_profile()`. +If you'd like to have these options loaded when you start up RStudio, edit your `.Rprofile`. An easy way to accomplish this is with `usethis::edit_r_profile()`. ```{r} usethis::edit_r_profile() ``` -This will open your `.Rprofile`. +This will open your `.Rprofile`. +Then, add `councilR.uid` and `councilR.pwd` to the list of options. ```{r, eval=FALSE} options( ..., From 37be3e632b59787a28c63ddf103449b4923901eb Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 14:06:31 -0400 Subject: [PATCH 06/50] use httr2 for secret management --- tests/testthat/test-import_from_emissions.R | 32 ++++++++++++--------- tests/testthat/test-import_from_gis.R | 27 ++++++++++------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/tests/testthat/test-import_from_emissions.R b/tests/testthat/test-import_from_emissions.R index 5896a29..f4b6186 100644 --- a/tests/testthat/test-import_from_emissions.R +++ b/tests/testthat/test-import_from_emissions.R @@ -1,28 +1,34 @@ # basic testing -testthat::expect_error( - mod_2 <- import_from_emissions( - local = FALSE, - table_name = "metro_energy.vw_electricity_residential_ctu" - ) -) +test_that("When local == FALSE, return an error message", + { + testthat::expect_error( + mod_2 <- import_from_emissions( + local = FALSE, + table_name = "metro_energy.vw_electricity_residential_ctu" + ) + ) + }) # skip on GH Actions testthat::skip_on_ci() +testthat::skip_on_cran() # skip if not connected to VPN testthat::skip_if( is.null(curl::nslookup("mc.local")) ) -# skip if "councilR.uid" option() is not set -testthat::skip_if(is.null(getOption("councilR.uid"))) -testthat::skip_if(is.null(getOption("councilR.pwd"))) +testthat::skip_if(httr2::secret_has_key("QUHBRb_yoy2RRj59qno8NVXA7mW402xkins")) +testthat::test_that("Residential electricity data is returned", { -electric_residential <- import_from_emissions( - table_name = "metro_energy.vw_electricity_residential_ctu" -) + electric_residential <- import_from_emissions( + uid = httr2::secret_decrypt("QUHBRb_yoy2RRj59qno8NVXA7mW402xkins", "COUNCILR_KEY"), + pwd = httr2::secret_decrypt("YXJZM6G8aHF-KTXwGiUx4Zm04qmRfERs", "COUNCILR_KEY"), + table_name = "metro_energy.vw_electricity_residential_ctu" + ) -testthat::expect_equal(nrow(electric_residential), 186) + testthat::expect_equal(nrow(electric_residential), 186) +}) diff --git a/tests/testthat/test-import_from_gis.R b/tests/testthat/test-import_from_gis.R index 9d1da29..7b90d0b 100644 --- a/tests/testthat/test-import_from_gis.R +++ b/tests/testthat/test-import_from_gis.R @@ -1,4 +1,4 @@ -# basic testing +# Can import_from_gis() actually import from the GISLibrary database? # skip on GH Actions testthat::skip_on_ci() @@ -8,16 +8,23 @@ testthat::skip_if( is.null(curl::nslookup("mc.local")) ) -# skip if "councilR.uid" option() is not set -testthat::skip_if(is.null(getOption("councilR.uid"))) -testthat::skip_if(is.null(getOption("councilR.pwd"))) +testthat::skip_if(httr2::secret_has_key("QUHBRb_yoy2RRj59qno8NVXA7mW402xkins")) # test return object attributes -airport <- import_from_gis( - query = "GISLibrary.dbo.AIRPORTS", - dbname = "GISLibrary" -) +testthat::test_that("airports spatial dataset", { + + airport <- import_from_gis( + uid = httr2::secret_decrypt("QUHBRb_yoy2RRj59qno8NVXA7mW402xkins", "COUNCILR_KEY"), + pwd = httr2::secret_decrypt("YXJZM6G8aHF-KTXwGiUx4Zm04qmRfERs", "COUNCILR_KEY"), + query = "GISLibrary.dbo.AIRPORTS", + dbname = "GISLibrary" + ) + + # test that all airports are included + # there should be 14 airports + testthat::expect_equal(nrow(airport), 14) -testthat::expect_equal(nrow(airport), 14) -testthat::expect_equal(class(airport)[[1]], "sf") + # test that object returned is an sf object + testthat::expect_equal(class(airport)[[1]], "sf") +}) From 4da1307ed80afc88504bac1fa4b796bb2821b6fe Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 14:06:51 -0400 Subject: [PATCH 07/50] add httr2 dependency --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index adf88d1..bd5fba9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,6 +37,7 @@ Suggests: cowplot (>= 1.1.1), curl (>= 4.3.2), details (>= 0.2.1), + httr2 (>= 0.2.1), knitr (>= 1.37), repmis (>= 0.5), rmarkdown (>= 2.11), From d7412c3b43fd85db7d96ac20207a50646193f0ff Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 14:19:10 -0400 Subject: [PATCH 08/50] ignore key setup doc --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d059856..6850137 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ docs/ inst/doc /doc/ /Meta/ +inst/r/key_setup.R From a6c131cc20f1bd95fd1b87eb4f8c6d83deb2bdd9 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 14:19:27 -0400 Subject: [PATCH 09/50] ignore key setup --- .Rbuildignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.Rbuildignore b/.Rbuildignore index 772c53b..7594f5c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,3 +12,4 @@ ^inst/presentations/a_brief_introduction$ ^doc$ ^Meta$ +^inst/r/key_setup\.R$ From 486df005bf3129483a6eef14cf4215d67c0824c0 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 14:19:41 -0400 Subject: [PATCH 10/50] update package description --- DESCRIPTION | 4 ++-- man/councilR-package.Rd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bd5fba9..1e42c82 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,8 +13,8 @@ Authors@R: c( comment = c(ORCID = "0000-0002-4253-0910")), person("Mauricio", "León", , "mauricio.leon@metc.state.mn.us", role = "ctb") ) -Description: A collection of commonly used templates, color palettes, - functions, and more! +Description: A collection of commonly used templates, color palettes, and + functions for R users at the Metropolitan Council. License: MIT + file LICENSE BugReports: https://github.com/Metropolitan-Council/councilR/issues Depends: diff --git a/man/councilR-package.Rd b/man/councilR-package.Rd index 267260f..7d790e2 100644 --- a/man/councilR-package.Rd +++ b/man/councilR-package.Rd @@ -6,7 +6,7 @@ \alias{councilR-package} \title{councilR: Functions and Templates for the Metropolitan Council} \description{ -A collection of commonly used templates, color palettes, functions, and more! +A collection of commonly used templates, color palettes, and functions for R users at the Metropolitan Council. } \seealso{ Useful links: From 0374b7ed4569c62eba190389ac42957dd8096d44 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 14:23:16 -0400 Subject: [PATCH 11/50] use tidy contribution guide --- .github/CONTRIBUTING.md | 42 +++++++++++++++++++++++++++++++++++++++++ README.Rmd | 10 +--------- README.md | 17 +---------------- 3 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 .github/CONTRIBUTING.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..969795a --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,42 @@ +# Contributing to councilR + +This outlines how to propose a change to councilR. +For more detailed info about contributing to this, and other tidyverse packages, please see the +[**development contributing guide**](https://rstd.io/tidy-contrib). + +## Fixing typos + +You can fix typos, spelling mistakes, or grammatical errors in the documentation directly using the GitHub web interface, as long as the changes are made in the _source_ file. +This generally means you'll need to edit [roxygen2 comments](https://roxygen2.r-lib.org/articles/roxygen2.html) in an `.R`, not a `.Rd` file. +You can find the `.R` file that generates the `.Rd` by reading the comment in the first line. + +## Bigger changes + +If you want to make a bigger change, it's a good idea to first file an issue and make sure someone from the team agrees that it’s needed. +If you’ve found a bug, please file an issue that illustrates the bug with a minimal +[reprex](https://www.tidyverse.org/help/#reprex) (this will also help you write a unit test, if needed). + +### Pull request process + +* Fork the package and clone onto your computer. If you haven't done this before, we recommend using `usethis::create_from_github("Metropolitan-Council/councilR", fork = TRUE)`. + +* Install all development dependencies with `devtools::install_dev_deps()`, and then make sure the package passes R CMD check by running `devtools::check()`. + If R CMD check doesn't pass cleanly, it's a good idea to ask for help before continuing. +* Create a Git branch for your pull request (PR). We recommend using `usethis::pr_init("brief-description-of-change")`. + +* Make your changes, commit to git, and then create a PR by running `usethis::pr_push()`, and following the prompts in your browser. + The title of your PR should briefly describe the change. + The body of your PR should contain `Fixes #issue-number`. + +* For user-facing changes, add a bullet to the top of `NEWS.md` (i.e. just below the first header). Follow the style described in . + +### Code style + +* New code should follow the tidyverse [style guide](https://style.tidyverse.org). + You can use the [styler](https://CRAN.R-project.org/package=styler) package to apply these styles, but please don't restyle code that has nothing to do with your PR. + +* We use [roxygen2](https://cran.r-project.org/package=roxygen2), with [Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/rd-formatting.html), for documentation. + +* We use [testthat](https://cran.r-project.org/package=testthat) for unit tests. + Contributions with test cases included are easier to accept. + diff --git a/README.Rmd b/README.Rmd index adec6ae..585eff5 100644 --- a/README.Rmd +++ b/README.Rmd @@ -32,15 +32,7 @@ remotes::install_github("Metropolitan-Council/councilR") ## Contributing -Clone this repository and make a new branch. When you are ready to submit your contribution for testing and review, write a pull request to the `main` branch. - -Generally, you should write tests for all R functions using [`{testthat}`](https://testthat.r-lib.org/). All functions must have documentation using [`{roxygen2}`](https://roxygen2.r-lib.org/). Changes to package dependencies, additions to `.Rbuildignore`, and data must be created using [`{usethis}`](https://usethis.r-lib.org/). - -Finally, be sure to add your name to the authors section in the `DESCRIPTION`. - -Please note that the `{councilR}` project is released with a -[Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). -By contributing to this project, you agree to abide by its terms. +Please see our contribution guidelines [here](.github/CONTRIBUTING.md). ### Acknowledgements diff --git a/README.md b/README.md index 7ff9b0d..97505b0 100644 --- a/README.md +++ b/README.md @@ -23,22 +23,7 @@ remotes::install_github("Metropolitan-Council/councilR") ## Contributing -Clone this repository and make a new branch. When you are ready to -submit your contribution for testing and review, write a pull request to -the `main` branch. - -Generally, you should write tests for all R functions using -[`{testthat}`](https://testthat.r-lib.org/). All functions must have -documentation using [`{roxygen2}`](https://roxygen2.r-lib.org/). Changes -to package dependencies, additions to `.Rbuildignore`, and data must be -created using [`{usethis}`](https://usethis.r-lib.org/). - -Finally, be sure to add your name to the authors section in the -`DESCRIPTION`. - -Please note that the `{councilR}` project is released with a -[Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). By -contributing to this project, you agree to abide by its terms. +Please see our contribution guidelines [here](.github/CONTRIBUTING.md) ### Acknowledgements From 55bd861e3e8afa25be5c3d9888b4b48fb248c83d Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 14:23:24 -0400 Subject: [PATCH 12/50] remove CoC --- .github/CODE_OF_CONDUCT.md | 128 ------------------------------------- 1 file changed, 128 deletions(-) delete mode 100644 .github/CODE_OF_CONDUCT.md diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md deleted file mode 100644 index b36903f..0000000 --- a/.github/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,128 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, religion, or sexual identity and -orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, -and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall -community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or -advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email -address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a -professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards -of acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies -when an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at [INSERT CONTACT -METHOD]. All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of -actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the -community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.0, -available at https://www.contributor-covenant.org/version/2/0/ -code_of_conduct.html. - -Community Impact Guidelines were inspired by [Mozilla's code of conduct -enforcement ladder](https://github.com/mozilla/diversity). - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at https:// -www.contributor-covenant.org/translations. From b31fc4ceb0d4d95dec775a2d1855d239e70de939 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 14:28:33 -0400 Subject: [PATCH 13/50] stye all --- R/import_from_emissions.R | 8 ++++---- R/theme_council.R | 11 +++++++---- tests/testthat/test-colors.R | 5 ----- tests/testthat/test-import_from_emissions.R | 18 ++++++++---------- tests/testthat/test-import_from_gis.R | 1 - 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/R/import_from_emissions.R b/R/import_from_emissions.R index aeb13c5..22e757a 100644 --- a/R/import_from_emissions.R +++ b/R/import_from_emissions.R @@ -59,7 +59,7 @@ import_from_emissions <- function(table_name, } # check that DB connection works - if(drv == "FreeTDS"){ + if (drv == "FreeTDS") { if ( DBI::dbCanConnect( odbc::odbc(), @@ -71,7 +71,7 @@ import_from_emissions <- function(table_name, ) == FALSE) { stop("Database failed to connect") } - } else if (drv == "SQL Server"){ + } else if (drv == "SQL Server") { if ( DBI::dbCanConnect( odbc::odbc(), @@ -89,7 +89,7 @@ import_from_emissions <- function(table_name, conn <- - if(drv == "FreeTDS"){ + if (drv == "FreeTDS") { DBI::dbConnect( odbc::odbc(), Driver = drv, @@ -98,7 +98,7 @@ import_from_emissions <- function(table_name, Pwd = pwd, Server = serv ) - } else if(drv == "SQL Server"){ + } else if (drv == "SQL Server") { DBI::dbConnect( odbc::odbc(), Driver = drv, diff --git a/R/theme_council.R b/R/theme_council.R index 70d7d0b..76f96da 100644 --- a/R/theme_council.R +++ b/R/theme_council.R @@ -105,14 +105,17 @@ theme_council <- function(base_size = 11, requireNamespace("showtext", quietly = TRUE) showtext::showtext_auto() - if(grepl("mac", osVersion)){ + if (grepl("mac", osVersion)) { sysfonts::font_paths() } else { # if windows, add the user-level font files to font paths sysfonts::font_paths( - paste0("C:\\Users\\", - Sys.info()["user"], - "\\AppData\\Local\\Microsoft\\Windows\\Fonts")) + paste0( + "C:\\Users\\", + Sys.info()["user"], + "\\AppData\\Local\\Microsoft\\Windows\\Fonts" + ) + ) } diff --git a/tests/testthat/test-colors.R b/tests/testthat/test-colors.R index 226a936..1c76c3e 100644 --- a/tests/testthat/test-colors.R +++ b/tests/testthat/test-colors.R @@ -1,12 +1,7 @@ test_that("Council Blue is correct color code", { - testthat::expect_equal(colors$councilBlue, "#0054A4") - }) test_that("All 29 colors are included", { - testthat::expect_equal(length(colors), 29L) - }) - diff --git a/tests/testthat/test-import_from_emissions.R b/tests/testthat/test-import_from_emissions.R index f4b6186..96c294e 100644 --- a/tests/testthat/test-import_from_emissions.R +++ b/tests/testthat/test-import_from_emissions.R @@ -1,14 +1,13 @@ # basic testing -test_that("When local == FALSE, return an error message", - { - testthat::expect_error( - mod_2 <- import_from_emissions( - local = FALSE, - table_name = "metro_energy.vw_electricity_residential_ctu" - ) - ) - }) +test_that("When local == FALSE, return an error message", { + testthat::expect_error( + mod_2 <- import_from_emissions( + local = FALSE, + table_name = "metro_energy.vw_electricity_residential_ctu" + ) + ) +}) # skip on GH Actions @@ -23,7 +22,6 @@ testthat::skip_if( testthat::skip_if(httr2::secret_has_key("QUHBRb_yoy2RRj59qno8NVXA7mW402xkins")) testthat::test_that("Residential electricity data is returned", { - electric_residential <- import_from_emissions( uid = httr2::secret_decrypt("QUHBRb_yoy2RRj59qno8NVXA7mW402xkins", "COUNCILR_KEY"), pwd = httr2::secret_decrypt("YXJZM6G8aHF-KTXwGiUx4Zm04qmRfERs", "COUNCILR_KEY"), diff --git a/tests/testthat/test-import_from_gis.R b/tests/testthat/test-import_from_gis.R index 7b90d0b..f34734a 100644 --- a/tests/testthat/test-import_from_gis.R +++ b/tests/testthat/test-import_from_gis.R @@ -13,7 +13,6 @@ testthat::skip_if(httr2::secret_has_key("QUHBRb_yoy2RRj59qno8NVXA7mW402xkins")) # test return object attributes testthat::test_that("airports spatial dataset", { - airport <- import_from_gis( uid = httr2::secret_decrypt("QUHBRb_yoy2RRj59qno8NVXA7mW402xkins", "COUNCILR_KEY"), pwd = httr2::secret_decrypt("YXJZM6G8aHF-KTXwGiUx4Zm04qmRfERs", "COUNCILR_KEY"), From d65f3aeec5f5e807dfc0024cd6db6f96fd3d057b Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 16:30:16 -0400 Subject: [PATCH 14/50] update docs --- R/snippets.R | 11 +++++------ man/snippets_install.Rd | 15 +++++++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/R/snippets.R b/R/snippets.R index 6a0abb2..23404e2 100644 --- a/R/snippets.R +++ b/R/snippets.R @@ -1,6 +1,5 @@ -#' Install councilR snippets -#' -#' This function installs a set of R snippets that +#' @title Install councilR snippets +#' @description This function installs a set of R snippets that #' are helpful when working with Metropolitan Council projects in in #' RStudio. By default, the snippets are installed where RStudio will find #' them. If you haven't previously installed snippets to RStudio, these @@ -30,10 +29,10 @@ #' snippets_install(snip_tmp) #' } #' -#' @param install_path Where should the snippets be installed? If `NULL`, the +#' @param install_path character, Where should the snippets be installed? If `NULL`, the #' snippets will install to a default path based on the current version of #' RStudio. -#' @param update Should existing snippets be updated in place if there are any +#' @param update logical, Should existing snippets be updated in place if there are any #' conflicts? Default is yes (`TRUE`). Otherwise, new snippets are appended to #' the end of the existing file, ensuring that you can recover your previous #' snippets by editing the snippets file. @@ -43,7 +42,7 @@ #' @importFrom fs path_home_r path dir_create dir_exists path_file dir_ls file_copy #' @importFrom glue glue #' @importFrom purrr map map_depth reduce flatten -#' +#' @family spatial helpers snippets_install <- function(install_path = NULL, update = TRUE) { # browser() new <- snippets_list("councilR") diff --git a/man/snippets_install.Rd b/man/snippets_install.Rd index 83ebdc6..781f189 100644 --- a/man/snippets_install.Rd +++ b/man/snippets_install.Rd @@ -3,22 +3,28 @@ \name{snippets_install} \alias{snippets_install} \alias{snippets} -\title{Install councilR snippets} +\title{Install councilR snippets +@description This function installs a set of R snippets that +are helpful when working with Metropolitan Council projects in in +RStudio. By default, the snippets are installed where RStudio will find +them. If you haven't previously installed snippets to RStudio, these +snippets will mask some of the built-in snippets that ship with RStudio.} \usage{ snippets_install(install_path = NULL, update = TRUE) } \arguments{ -\item{install_path}{Where should the snippets be installed? If \code{NULL}, the +\item{install_path}{character, Where should the snippets be installed? If \code{NULL}, the snippets will install to a default path based on the current version of RStudio.} -\item{update}{Should existing snippets be updated in place if there are any +\item{update}{logical, Should existing snippets be updated in place if there are any conflicts? Default is yes (\code{TRUE}). Otherwise, new snippets are appended to the end of the existing file, ensuring that you can recover your previous snippets by editing the snippets file.} } \description{ -This function installs a set of R snippets that +Install councilR snippets +@description This function installs a set of R snippets that are helpful when working with Metropolitan Council projects in in RStudio. By default, the snippets are installed where RStudio will find them. If you haven't previously installed snippets to RStudio, these @@ -54,3 +60,4 @@ snippets_install(snip_tmp) Garrick Aden-Buie \email{g.adenbuie@gmail.com}, Liz Roten \email{liz.roten@metc.state.mn.us} } +\concept{spatial helpers} From ee5200b60f38f1a67eef429d423ab51396729b74 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 16:57:33 -0400 Subject: [PATCH 15/50] new vignette explaining snippets, spatial functions --- vignettes/Spatial_helpers.Rmd | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 vignettes/Spatial_helpers.Rmd diff --git a/vignettes/Spatial_helpers.Rmd b/vignettes/Spatial_helpers.Rmd new file mode 100644 index 0000000..8d2588e --- /dev/null +++ b/vignettes/Spatial_helpers.Rmd @@ -0,0 +1,65 @@ +--- +title: "Spatial Helpers" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Spatial_helpers} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +```{r setup} +library(councilR) +``` + +`{councilR}` has a couple functions and snippets to help you access and manipulate spatial data. + +## Snippets +Once you have installed snippets using `councilR::snippets_install()`, you will now have important values quickly accessible. To access them, start typing the snippet name into the console. The snippet will autocomplete. + + - `metro_crs`, the numeric preferred coordinate reference system (CRS) for our region. Most commonly used when transforming a spatial object's projection with `sf::st_transform(df, 26915)` + - `tile_crs`, numeric coordinate reference system for spatial data using a tile-based system, like `{leaflet}`. Most commonly used with `sf::st_transform(df, 4326)` + - `metro_centroid`, vector with latitude and longitude coordinates of the geographic center of the 7-county metro. Useful for setting a starting center point and zoom in `{leaflet}` maps. + - `counties`, vector of county names for the seven core counties serviced by the Metropolitan Council + - `counties_mpo`, county names for all counties included in the Metropolitan Planning Organization (MPO) area. + +```{r, eval=FALSE} +metro_crs +#> 26915 + +metro_centroid +#> c(-93.30375, +#> 44.91831) +``` + +## Functions + +Some datasets are maintained on [Minnesota Geospatial Commons](https://gisdata.mn.gov/). These datasets generally mirror datasets available in the internal GISLibrary. On Minnesota Geospatial commons, navigate to the dataset you want to access. Find the button to download the OGC GeoPackage format, and right click on it. Select "Copy link address". The address will end with ".zip". + +Pass this link to `import_from_gpkg()` to get the [sf]() object! + +```{r} +regional_parks_commons <- import_from_gpkg("https://resources.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_metc/plan_parks_regional/gpkg_plan_parks_regional.zip") + +head(regional_parks_commons) +``` + +If you can access internal databases, use your Council login user ID and password to access data from the GIS Library. For seamless access, see `vignette("Options")` to review package options. + +```{r, eval = FALSE} +regional_parks_db <- import_from_gis(query = "PARKSREGIONAL") + +head(regional_parks_db) +``` +A commonly fetch spatial dataset is the 7-county geography. `fetch_counties()` does just that. + +```{r} +fetch_counties() +``` + From 883e7964dc75b73bd17392c396d7971cc528d512 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 25 Jul 2022 16:57:48 -0400 Subject: [PATCH 16/50] start fetch_counties() --- NAMESPACE | 3 +++ R/fetch_counties.R | 39 ++++++++++++++++++++++++++++ man/fetch_counties.Rd | 29 +++++++++++++++++++++ man/snippets_install.Rd | 4 +++ tests/testthat/test-fetch_counties.R | 7 +++++ 5 files changed, 82 insertions(+) create mode 100644 R/fetch_counties.R create mode 100644 man/fetch_counties.Rd create mode 100644 tests/testthat/test-fetch_counties.R diff --git a/NAMESPACE b/NAMESPACE index 653d320..ae699b9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,6 +4,7 @@ export("%>%") export(council.pal) export(council_pal2) export(council_theme) +export(fetch_counties) export(import_from_emissions) export(import_from_gis) export(import_from_gpkg) @@ -16,6 +17,7 @@ importFrom(DBI,dbCanConnect) importFrom(DBI,dbConnect) importFrom(DBI,dbDisconnect) importFrom(DBI,dbGetQuery) +importFrom(dplyr,filter) importFrom(fs,dir_create) importFrom(fs,dir_exists) importFrom(fs,dir_ls) @@ -48,6 +50,7 @@ importFrom(sf,st_as_sf) importFrom(sf,st_transform) importFrom(tictoc,tic) importFrom(tictoc,toc) +importFrom(tigris,counties) importFrom(utils,download.file) importFrom(utils,osVersion) importFrom(utils,tail) diff --git a/R/fetch_counties.R b/R/fetch_counties.R new file mode 100644 index 0000000..ea8f926 --- /dev/null +++ b/R/fetch_counties.R @@ -0,0 +1,39 @@ +#' @title Fetch standardized county geography +#' +#' @param core logical, whether to include all counties in the MPO. +#' @param ... Arguments passed to `[tigris::counties]` +#' @return An `[sf]` object containing the +#' @export +#' @family spatial helpers +#' @examples +#' \dontrun{ +#' fetch_counties() +#' } +#' @importFrom tigris counties +#' @importFrom dplyr filter +fetch_counties <- function(core = TRUE, ...){ + + county_list <- if(core == TRUE){ + c("Anoka", + "Carver", + "Dakota", + "Hennepin", + "Ramsey", + "Scott", + "Washington") + } else if(core == FALSE){ + c("Anoka", + "Carver", + "Dakota", + "Hennepin", + "Ramsey", + "Scott", + "Sherburne", + "Washington", + "Wright") + } + + tigris::counties(state = "MN", ...) %>% + dplyr::filter(.data$NAME %in% county_list) + +} diff --git a/man/fetch_counties.Rd b/man/fetch_counties.Rd new file mode 100644 index 0000000..1b8e826 --- /dev/null +++ b/man/fetch_counties.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fetch_counties.R +\name{fetch_counties} +\alias{fetch_counties} +\title{Fetch standardized county geography} +\usage{ +fetch_counties(core = TRUE, ...) +} +\arguments{ +\item{core}{logical, whether to include all counties in the MPO.} + +\item{...}{Arguments passed to \verb{[tigris::counties]}} +} +\value{ +An \verb{[sf]} object containing the +} +\description{ +Fetch standardized county geography +} +\examples{ +\dontrun{ +fetch_counties() +} +} +\seealso{ +Other spatial helpers: +\code{\link{snippets_install}()} +} +\concept{spatial helpers} diff --git a/man/snippets_install.Rd b/man/snippets_install.Rd index 781f189..a75ddb3 100644 --- a/man/snippets_install.Rd +++ b/man/snippets_install.Rd @@ -55,6 +55,10 @@ dir.create(snip_tmp) snippets_install(snip_tmp) } +} +\seealso{ +Other spatial helpers: +\code{\link{fetch_counties}()} } \author{ Garrick Aden-Buie \email{g.adenbuie@gmail.com}, diff --git a/tests/testthat/test-fetch_counties.R b/tests/testthat/test-fetch_counties.R new file mode 100644 index 0000000..a57e72f --- /dev/null +++ b/tests/testthat/test-fetch_counties.R @@ -0,0 +1,7 @@ +# test_that("correct counties are fetched", { +# +# # region_counties <- fetch_counties() +# # +# # testthat::expect_equal(nrow(region_counties, 7)) +# +# }) From 762087dfc2cbe02cb59c456991b36d97c1ee2820 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 11:58:49 -0400 Subject: [PATCH 17/50] chang file name; use cli for messaging; do not use dplyr --- R/{fetch_counties.R => fetch_county_geo.R} | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) rename R/{fetch_counties.R => fetch_county_geo.R} (57%) diff --git a/R/fetch_counties.R b/R/fetch_county_geo.R similarity index 57% rename from R/fetch_counties.R rename to R/fetch_county_geo.R index ea8f926..95ffd7c 100644 --- a/R/fetch_counties.R +++ b/R/fetch_county_geo.R @@ -7,11 +7,18 @@ #' @family spatial helpers #' @examples #' \dontrun{ -#' fetch_counties() +#' fetch_county_geo() #' } +#'# importFrom can only access functions that are exported from the package #' @importFrom tigris counties -#' @importFrom dplyr filter -fetch_counties <- function(core = TRUE, ...){ +#' @importFrom cli cli_abort +fetch_county_geo <- function(core = TRUE, ...){ + + suppressWarnings( + if(class(core) != "logical"){ + cli::cli_abort("`core` must be a logical, not {rlang:::obj_type_friendly(core)}.") + } + ) county_list <- if(core == TRUE){ c("Anoka", @@ -33,7 +40,12 @@ fetch_counties <- function(core = TRUE, ...){ "Wright") } - tigris::counties(state = "MN", ...) %>% - dplyr::filter(.data$NAME %in% county_list) + # fetch county geograp + mn_counties <- tigris::counties(state = "MN", ...) + + county_sf <- mn_counties[mn_counties$NAME %in% county_list,] + + + return(county_sf) } From 23d9a6a5ff119042547a36b6e66443b19be05882 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 11:59:12 -0400 Subject: [PATCH 18/50] make new tests for fetch_county_geo() --- tests/testthat/test-fetch_counties.R | 7 ------- tests/testthat/test-fetch_county_geo.R | 5 +++++ 2 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 tests/testthat/test-fetch_counties.R create mode 100644 tests/testthat/test-fetch_county_geo.R diff --git a/tests/testthat/test-fetch_counties.R b/tests/testthat/test-fetch_counties.R deleted file mode 100644 index a57e72f..0000000 --- a/tests/testthat/test-fetch_counties.R +++ /dev/null @@ -1,7 +0,0 @@ -# test_that("correct counties are fetched", { -# -# # region_counties <- fetch_counties() -# # -# # testthat::expect_equal(nrow(region_counties, 7)) -# -# }) diff --git a/tests/testthat/test-fetch_county_geo.R b/tests/testthat/test-fetch_county_geo.R new file mode 100644 index 0000000..6a9d491 --- /dev/null +++ b/tests/testthat/test-fetch_county_geo.R @@ -0,0 +1,5 @@ +test_that("input check works", { + + testthat::expect_error(fetch_county_geo(core = "foo")) + +}) From 5a744527e8c0523e1119224afb0ca59ae6f0e90d Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 11:59:38 -0400 Subject: [PATCH 19/50] import `{cli}` --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 1e42c82..8c83fdc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,6 +20,7 @@ BugReports: https://github.com/Metropolitan-Council/councilR/issues Depends: R (>= 2.10) Imports: + cli (>= 3.3.0), DBI (>= 1.1.0), fs (>= 1.4), ggplot2 (>= 3.3.0), From a514fd9a4f9cc6a895314545fc7e7d24936c7ad9 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 12:02:13 -0400 Subject: [PATCH 20/50] document --- NAMESPACE | 4 +-- R/fetch_county_geo.R | 28 +++++++++++-------- ...{fetch_counties.Rd => fetch_county_geo.Rd} | 14 ++++++---- man/snippets_install.Rd | 2 +- 4 files changed, 28 insertions(+), 20 deletions(-) rename man/{fetch_counties.Rd => fetch_county_geo.Rd} (64%) diff --git a/NAMESPACE b/NAMESPACE index ae699b9..5c8c2d9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,7 +4,7 @@ export("%>%") export(council.pal) export(council_pal2) export(council_theme) -export(fetch_counties) +export(fetch_county_geo) export(import_from_emissions) export(import_from_gis) export(import_from_gpkg) @@ -17,7 +17,7 @@ importFrom(DBI,dbCanConnect) importFrom(DBI,dbConnect) importFrom(DBI,dbDisconnect) importFrom(DBI,dbGetQuery) -importFrom(dplyr,filter) +importFrom(cli,cli_abort) importFrom(fs,dir_create) importFrom(fs,dir_exists) importFrom(fs,dir_ls) diff --git a/R/fetch_county_geo.R b/R/fetch_county_geo.R index 95ffd7c..7ecd54c 100644 --- a/R/fetch_county_geo.R +++ b/R/fetch_county_geo.R @@ -9,27 +9,31 @@ #' \dontrun{ #' fetch_county_geo() #' } -#'# importFrom can only access functions that are exported from the package +#' +#' @note This function relies on `[rlang:::obj_type_friendly()]`, an internal function. +#' #' @importFrom tigris counties #' @importFrom cli cli_abort -fetch_county_geo <- function(core = TRUE, ...){ - +fetch_county_geo <- function(core = TRUE, ...) { suppressWarnings( - if(class(core) != "logical"){ + if (class(core) != "logical") { cli::cli_abort("`core` must be a logical, not {rlang:::obj_type_friendly(core)}.") } ) - county_list <- if(core == TRUE){ - c("Anoka", + county_list <- if (core == TRUE) { + c( + "Anoka", "Carver", "Dakota", "Hennepin", "Ramsey", "Scott", - "Washington") - } else if(core == FALSE){ - c("Anoka", + "Washington" + ) + } else if (core == FALSE) { + c( + "Anoka", "Carver", "Dakota", "Hennepin", @@ -37,15 +41,15 @@ fetch_county_geo <- function(core = TRUE, ...){ "Scott", "Sherburne", "Washington", - "Wright") + "Wright" + ) } # fetch county geograp mn_counties <- tigris::counties(state = "MN", ...) - county_sf <- mn_counties[mn_counties$NAME %in% county_list,] + county_sf <- mn_counties[mn_counties$NAME %in% county_list, ] return(county_sf) - } diff --git a/man/fetch_counties.Rd b/man/fetch_county_geo.Rd similarity index 64% rename from man/fetch_counties.Rd rename to man/fetch_county_geo.Rd index 1b8e826..fe0f1c4 100644 --- a/man/fetch_counties.Rd +++ b/man/fetch_county_geo.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/fetch_counties.R -\name{fetch_counties} -\alias{fetch_counties} +% Please edit documentation in R/fetch_county_geo.R +\name{fetch_county_geo} +\alias{fetch_county_geo} \title{Fetch standardized county geography} \usage{ -fetch_counties(core = TRUE, ...) +fetch_county_geo(core = TRUE, ...) } \arguments{ \item{core}{logical, whether to include all counties in the MPO.} @@ -17,10 +17,14 @@ An \verb{[sf]} object containing the \description{ Fetch standardized county geography } +\note{ +This function relies on \verb{[rlang:::obj_type_friendly()]}, an internal function. +} \examples{ \dontrun{ -fetch_counties() +fetch_county_geo() } + } \seealso{ Other spatial helpers: diff --git a/man/snippets_install.Rd b/man/snippets_install.Rd index a75ddb3..d810a2e 100644 --- a/man/snippets_install.Rd +++ b/man/snippets_install.Rd @@ -58,7 +58,7 @@ snippets_install(snip_tmp) } \seealso{ Other spatial helpers: -\code{\link{fetch_counties}()} +\code{\link{fetch_county_geo}()} } \author{ Garrick Aden-Buie \email{g.adenbuie@gmail.com}, From 01d8cdfa76c838ee02373e9bfc02acb6b5788012 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 14:48:36 -0400 Subject: [PATCH 21/50] import rlang --- R/snippets.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/snippets.R b/R/snippets.R index 23404e2..d18f8c7 100644 --- a/R/snippets.R +++ b/R/snippets.R @@ -41,7 +41,8 @@ #' #' @importFrom fs path_home_r path dir_create dir_exists path_file dir_ls file_copy #' @importFrom glue glue -#' @importFrom purrr map map_depth reduce flatten +#' @importFrom purrr map map_depth reduce +#' @importFrom rlang flatten #' @family spatial helpers snippets_install <- function(install_path = NULL, update = TRUE) { # browser() From 21e20fccbbb15fab32cd38b1f61abb29fd5f4136 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 14:48:53 -0400 Subject: [PATCH 22/50] update snippet docs --- R/snippets.R | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/R/snippets.R b/R/snippets.R index d18f8c7..487b544 100644 --- a/R/snippets.R +++ b/R/snippets.R @@ -1,12 +1,12 @@ #' @title Install councilR snippets -#' @description This function installs a set of R snippets that +#' +#' @description This function installs a set of R snippets that #' are helpful when working with Metropolitan Council projects in in #' RStudio. By default, the snippets are installed where RStudio will find #' them. If you haven't previously installed snippets to RStudio, these #' snippets will mask some of the built-in snippets that ship with RStudio. #' -#' @note This function is adapted from -#' \href{https://github.com/gadenbuie/js4shiny/blob/master/R/snippets.R}{js4shiny::snippets_install()}. +#' @note This function is adapted from [`js4shiny::snippets_install()`](https://github.com/gadenbuie/js4shiny/blob/main/R/snippets.R) #' #' @section Updating Existing Snippets: If you already have snippets installed, #' you can you can have the installed snippets update the existing snippets @@ -29,10 +29,10 @@ #' snippets_install(snip_tmp) #' } #' -#' @param install_path character, Where should the snippets be installed? If `NULL`, the -#' snippets will install to a default path based on the current version of +#' @param install_path character, where should the snippets be installed? If `NULL`, +#' the snippets will install to a default path based on the current version of #' RStudio. -#' @param update logical, Should existing snippets be updated in place if there are any +#' @param update logical, should existing snippets be updated in place if there are any #' conflicts? Default is yes (`TRUE`). Otherwise, new snippets are appended to #' the end of the existing file, ensuring that you can recover your previous #' snippets by editing the snippets file. @@ -154,7 +154,7 @@ snippets_merge <- function(new, old) { names(.x) <- nm .x }) %>% - purrr::flatten() + rlang::flatten() new_snps <- setdiff(names(snps$new), names(snps$old)) merged <- c() From ce3a64c0918764f4ee681c66cc9e5920af64f0ce Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 14:49:42 -0400 Subject: [PATCH 23/50] note rlang dependency --- R/import_from_emissions.R | 2 ++ R/import_from_gis.R | 5 ++++- R/import_from_gpkg.R | 2 ++ R/theme_council.R | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/R/import_from_emissions.R b/R/import_from_emissions.R index 22e757a..ea16dde 100644 --- a/R/import_from_emissions.R +++ b/R/import_from_emissions.R @@ -19,6 +19,8 @@ #' **Mac** users need `unixodbc` and `freetds`. See instructions in #' [`{MetroTransitR}`](https://github.com/Metropolitan-Council/MetroTransitR) #' +#' This function relies on `[{rlang}]` internal functions. +#' #' @return Requested table #' @export #' diff --git a/R/import_from_gis.R b/R/import_from_gis.R index e2afb30..3afcfc5 100644 --- a/R/import_from_gis.R +++ b/R/import_from_gis.R @@ -3,13 +3,16 @@ #' @param query character, string with the database connection and feature class #' @param dbname character, database name. Default is `"GISLibrary"`. #' Must match the database name in `query`. -#' @param uid character, user ID. default is `getOption("councilR.uid")` +#' @param uid character, user ID. Default is `getOption("councilR.uid")` #' @param pwd character, user password. Default is `getOption("councilR.pwd")`. #' #' @note See `vignette("Options")` to review package options. #' You must be set up with the appropriate database drivers to use this function. #' **Windows** users need ODBC with Microsoft SQL. Contact IS support for ODBC installation. #' **Mac** users need `unixodbc` and `freetds`. See instructions in [`{MetroTransitR}`](https://github.com/Metropolitan-Council/MetroTransitR) +#' +#' This function relies on `[{rlang}]` internal functions. +#' #' @return an `sf` object #' @export #' @examples \dontrun{ diff --git a/R/import_from_gpkg.R b/R/import_from_gpkg.R index 8ed4e3b..afd8603 100644 --- a/R/import_from_gpkg.R +++ b/R/import_from_gpkg.R @@ -17,6 +17,8 @@ #' @description Particularly useful for importing data from Minnesota Geospatial Commons #' when access to the internal GIS database is unavailable. #' +#' @note This function relies on `[{rlang}]` internal functions. +#' #' @importFrom sf read_sf st_transform #' @importFrom fs file_delete #' @importFrom utils download.file tail unzip diff --git a/R/theme_council.R b/R/theme_council.R index 76f96da..900c1be 100644 --- a/R/theme_council.R +++ b/R/theme_council.R @@ -64,7 +64,7 @@ #' a pull request. #' #' -#' +#' @note This function relies on `[{rlang}]` internal functions. #' #' @examples #' \dontrun{ From bad6105913c3357136947a4e012d5ab6c6d71afa Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 14:50:50 -0400 Subject: [PATCH 24/50] use purrr::map() and rlang functions for input checking --- R/fetch_county_geo.R | 10 ++++------ R/import_from_emissions.R | 13 +++++++++++++ R/import_from_gis.R | 6 ++++++ R/import_from_gpkg.R | 30 ++++++++++++++++++++++++------ R/theme_council.R | 14 ++++++++++++++ 5 files changed, 61 insertions(+), 12 deletions(-) diff --git a/R/fetch_county_geo.R b/R/fetch_county_geo.R index 7ecd54c..0dbca4d 100644 --- a/R/fetch_county_geo.R +++ b/R/fetch_county_geo.R @@ -10,16 +10,14 @@ #' fetch_county_geo() #' } #' -#' @note This function relies on `[rlang:::obj_type_friendly()]`, an internal function. +#' @note This function relies on `[{rlang}]` internal functions. #' #' @importFrom tigris counties #' @importFrom cli cli_abort +#' @importFrom purrr map +#' fetch_county_geo <- function(core = TRUE, ...) { - suppressWarnings( - if (class(core) != "logical") { - cli::cli_abort("`core` must be a logical, not {rlang:::obj_type_friendly(core)}.") - } - ) + rlang:::check_bool(core) county_list <- if (core == TRUE) { c( diff --git a/R/import_from_emissions.R b/R/import_from_emissions.R index ea16dde..5b5f081 100644 --- a/R/import_from_emissions.R +++ b/R/import_from_emissions.R @@ -41,12 +41,25 @@ #' @importFrom DBI dbCanConnect dbGetQuery dbConnect dbDisconnect #' @importFrom odbc odbc #' @importFrom utils osVersion +#' @importFrom purrr map +#' import_from_emissions <- function(table_name, uid = getOption("councilR.uid"), pwd = getOption("councilR.pwd"), local = TRUE, serv = "dbsqlcl11t.test.local,65414", db = "CD_Emissions") { + + # check input types + purrr::map( + c(table_name, serv, uid, pwd, db), + rlang:::check_string + ) + purrr::map( + c(local), + rlang:::check_bool + ) + # browser() # decide which driver to use based on OS diff --git a/R/import_from_gis.R b/R/import_from_gis.R index 3afcfc5..43e05d2 100644 --- a/R/import_from_gis.R +++ b/R/import_from_gis.R @@ -27,10 +27,16 @@ #' @importFrom odbc odbc #' @importFrom DBI dbGetQuery dbDisconnect dbCanConnect dbConnect #' @importFrom tictoc tic toc +#' @importFrom purrr map import_from_gis <- function(query, dbname = "GISLibrary", uid = getOption("councilR.uid"), pwd = getOption("councilR.pwd")) { + purrr::map( + c(query, dbname, uid, pwd), + rlang:::check_string + ) + tictoc::tic() if (DBI::dbCanConnect(odbc::odbc(), # driver = "FreeTDS", diff --git a/R/import_from_gpkg.R b/R/import_from_gpkg.R index afd8603..2ced34e 100644 --- a/R/import_from_gpkg.R +++ b/R/import_from_gpkg.R @@ -1,12 +1,12 @@ -#' Import an `sf` object using a URL +#' @title Import an `sf` object using a URL #' #' @param link character, URL for the `.gpkg` object #' @param save_file logical, whether to save the downloaded file. #' File will be saved in .RDS format #' @param save_path character, the path where the downloaded file should be saved. -#' Default location is in the working directory. -#' @param .crs, the CRS code or string used to transform the download. -#' Default is "4326" (WGS 84) +#' Default location is the working directory. +#' @param .crs numeric, the CRS code or string used to transform the download. +#' Default is `4326` (WGS 84) #' @param keep_temp character, whether to keep the temporary download. #' Default is `FALSE`. #' @param .quiet logical, suppress messages @@ -22,28 +22,46 @@ #' @importFrom sf read_sf st_transform #' @importFrom fs file_delete #' @importFrom utils download.file tail unzip -#' +#' @importFrom purrr map #' @examples #' #' library(councilR) #' #' # import regional parks from Minnesota Geospatial Commons #' import_from_gpkg("https://resources.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_metc/plan_parks_regional/gpkg_plan_parks_regional.zip") +#' import_from_gpkg <- function(link, save_file = FALSE, save_path = getwd(), .crs = 4326, keep_temp = FALSE, .quiet = TRUE) { + + # check input types + purrr::map( + c(link), + rlang:::check_string + ) + purrr::map( + c(save_file, keep_temp, .quiet), + rlang:::check_bool + ) + rlang:::check_string(save_path) + rlang:::check_number(.crs) + + # download to a temp file temp <- tempfile() download.file(link, temp, quiet = .quiet) + # get file names file_names <- strsplit(link, split = "/") + # fetch the core file name file_name <- tail(file_names[[1]], 1) %>% gsub(pattern = "gpkg_", replacement = "") %>% gsub(pattern = ".zip", replacement = "") + # read in the gpkg as an sf out_sf <- sf::read_sf(unzip(temp, paste0(file_name, ".gpkg")), quiet = .quiet, ) %>% sf::st_transform(crs = .crs) @@ -52,7 +70,7 @@ import_from_gpkg <- function(link, fs::file_delete(paste0(file_name, ".gpkg")) } - # save the cle + # write the transformed sf if (save_file == TRUE) { saveRDS(out_sf, paste0(save_path, "/", file_name, ".RDS")) } diff --git a/R/theme_council.R b/R/theme_council.R index 900c1be..2e79cbe 100644 --- a/R/theme_council.R +++ b/R/theme_council.R @@ -82,6 +82,7 @@ #' } #' #' @importFrom ggplot2 theme element_text element_blank element_rect element_line margin unit rel %+replace% +#' @importFrom purrr map #' #' theme_council <- function(base_size = 11, @@ -100,6 +101,19 @@ theme_council <- function(base_size = 11, "caption" = 8, "strip" = 14 )) { + purrr::map( + c(use_showtext, use_manual_font_sizes), + rlang:::check_bool + ) + + purrr::map(c(base_size, + base_line_size, + base_rect_size, + ), + rlang:::check_number) + + rlang:::check_string(base_family) + if (use_showtext == TRUE) { requireNamespace("sysfonts", quietly = TRUE) requireNamespace("showtext", quietly = TRUE) From 3cbdd5d4666cf336e1fe748c25b974177c5afeb1 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 14:50:55 -0400 Subject: [PATCH 25/50] update README --- README.Rmd | 2 +- README.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.Rmd b/README.Rmd index 585eff5..c6a3e38 100644 --- a/README.Rmd +++ b/README.Rmd @@ -20,7 +20,7 @@ knitr::opts_chunk$set( [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) -The goal of `{councilR}` is to provide a curated collection of commonly used templates, color palettes, snippets, functions, and more! +`{councilR`} is a collection of commonly used templates, color palettes, and functions for R users at the Metropolitan Council. ## Installation diff --git a/README.md b/README.md index 97505b0..716bc83 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) -The goal of `{councilR}` is to provide a curated collection of commonly -used templates, color palettes, snippets, functions, and more! +`{councilR`} is a collection of commonly used templates, color palettes, +and functions for R users at the Metropolitan Council. ## Installation @@ -23,7 +23,7 @@ remotes::install_github("Metropolitan-Council/councilR") ## Contributing -Please see our contribution guidelines [here](.github/CONTRIBUTING.md) +Please see our contribution guidelines [here](.github/CONTRIBUTING.md). ### Acknowledgements From a0dd4a62eb33ba7aefda7fbe69ede7943d9ac9fa Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 14:52:22 -0400 Subject: [PATCH 26/50] use purrr::flatten() --- R/snippets.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/snippets.R b/R/snippets.R index 487b544..05335d0 100644 --- a/R/snippets.R +++ b/R/snippets.R @@ -42,7 +42,7 @@ #' @importFrom fs path_home_r path dir_create dir_exists path_file dir_ls file_copy #' @importFrom glue glue #' @importFrom purrr map map_depth reduce -#' @importFrom rlang flatten +#' @importFrom purrr flatten #' @family spatial helpers snippets_install <- function(install_path = NULL, update = TRUE) { # browser() @@ -154,7 +154,7 @@ snippets_merge <- function(new, old) { names(.x) <- nm .x }) %>% - rlang::flatten() + purrr::flatten() new_snps <- setdiff(names(snps$new), names(snps$old)) merged <- c() From 2ee8fa1f78948549616fab6453c06158f26cc9de Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 14:52:27 -0400 Subject: [PATCH 27/50] update docs --- R/council_theme.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/council_theme.R b/R/council_theme.R index 7ccb5ca..a9dcec2 100644 --- a/R/council_theme.R +++ b/R/council_theme.R @@ -1,4 +1,4 @@ -#' Council ggplot2 theme +#' @title Council ggplot2 theme #' #' @param use_showtext Logical, whether to use Council fonts. #' @param size_header Header font size in pt. Default is 22 From f14b655ea3a2774edec5004b72b5f29609e63629 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 14:54:26 -0400 Subject: [PATCH 28/50] run styler --- R/theme_council.R | 13 ++++++++----- man/fetch_county_geo.Rd | 2 +- man/import_from_emissions.Rd | 3 +++ man/import_from_gis.Rd | 5 ++++- man/import_from_gpkg.Rd | 10 +++++++--- man/snippets_install.Rd | 19 ++++++------------- man/theme_council.Rd | 3 +++ tests/testthat/test-fetch_county_geo.R | 2 -- 8 files changed, 32 insertions(+), 25 deletions(-) diff --git a/R/theme_council.R b/R/theme_council.R index 2e79cbe..a875647 100644 --- a/R/theme_council.R +++ b/R/theme_council.R @@ -106,11 +106,14 @@ theme_council <- function(base_size = 11, rlang:::check_bool ) - purrr::map(c(base_size, - base_line_size, - base_rect_size, - ), - rlang:::check_number) + purrr::map( + c( + base_size, + base_line_size, + base_rect_size, + ), + rlang:::check_number + ) rlang:::check_string(base_family) diff --git a/man/fetch_county_geo.Rd b/man/fetch_county_geo.Rd index fe0f1c4..94b6815 100644 --- a/man/fetch_county_geo.Rd +++ b/man/fetch_county_geo.Rd @@ -18,7 +18,7 @@ An \verb{[sf]} object containing the Fetch standardized county geography } \note{ -This function relies on \verb{[rlang:::obj_type_friendly()]}, an internal function. +This function relies on \verb{[\{rlang\}]} internal functions. } \examples{ \dontrun{ diff --git a/man/import_from_emissions.Rd b/man/import_from_emissions.Rd index 48abdac..931b0d8 100644 --- a/man/import_from_emissions.Rd +++ b/man/import_from_emissions.Rd @@ -42,6 +42,9 @@ You must be set up with the appropriate database drivers to use this function. \strong{Windows} users need ODBC with Microsoft SQL. Contact IS support for ODBC installation. \strong{Mac} users need \code{unixodbc} and \code{freetds}. See instructions in \href{https://github.com/Metropolitan-Council/MetroTransitR}{\code{{MetroTransitR}}} + +\if{html}{\out{
}}\preformatted{This function relies on `[\{rlang\}]` internal functions. +}\if{html}{\out{
}} } \examples{ \dontrun{ diff --git a/man/import_from_gis.Rd b/man/import_from_gis.Rd index c6e5e9f..fc754c7 100644 --- a/man/import_from_gis.Rd +++ b/man/import_from_gis.Rd @@ -17,7 +17,7 @@ import_from_gis( \item{dbname}{character, database name. Default is \code{"GISLibrary"}. Must match the database name in \code{query}.} -\item{uid}{character, user ID. default is \code{getOption("councilR.uid")}} +\item{uid}{character, user ID. Default is \code{getOption("councilR.uid")}} \item{pwd}{character, user password. Default is \code{getOption("councilR.pwd")}.} } @@ -32,6 +32,9 @@ See \code{vignette("Options")} to review package options. You must be set up with the appropriate database drivers to use this function. \strong{Windows} users need ODBC with Microsoft SQL. Contact IS support for ODBC installation. \strong{Mac} users need \code{unixodbc} and \code{freetds}. See instructions in \href{https://github.com/Metropolitan-Council/MetroTransitR}{\code{{MetroTransitR}}} + +\if{html}{\out{
}}\preformatted{ This function relies on `[\{rlang\}]` internal functions. +}\if{html}{\out{
}} } \examples{ \dontrun{ diff --git a/man/import_from_gpkg.Rd b/man/import_from_gpkg.Rd index 1acfed6..3fb27ae 100644 --- a/man/import_from_gpkg.Rd +++ b/man/import_from_gpkg.Rd @@ -20,10 +20,10 @@ import_from_gpkg( File will be saved in .RDS format} \item{save_path}{character, the path where the downloaded file should be saved. -Default location is in the working directory.} +Default location is the working directory.} -\item{.crs, }{the CRS code or string used to transform the download. -Default is "4326" (WGS 84)} +\item{.crs}{numeric, the CRS code or string used to transform the download. +Default is \code{4326} (WGS 84)} \item{keep_temp}{character, whether to keep the temporary download. Default is \code{FALSE}.} @@ -37,10 +37,14 @@ an \code{sf} object Particularly useful for importing data from Minnesota Geospatial Commons when access to the internal GIS database is unavailable. } +\note{ +This function relies on \verb{[\{rlang\}]} internal functions. +} \examples{ library(councilR) # import regional parks from Minnesota Geospatial Commons import_from_gpkg("https://resources.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_metc/plan_parks_regional/gpkg_plan_parks_regional.zip") + } diff --git a/man/snippets_install.Rd b/man/snippets_install.Rd index d810a2e..89ae97a 100644 --- a/man/snippets_install.Rd +++ b/man/snippets_install.Rd @@ -3,28 +3,22 @@ \name{snippets_install} \alias{snippets_install} \alias{snippets} -\title{Install councilR snippets -@description This function installs a set of R snippets that -are helpful when working with Metropolitan Council projects in in -RStudio. By default, the snippets are installed where RStudio will find -them. If you haven't previously installed snippets to RStudio, these -snippets will mask some of the built-in snippets that ship with RStudio.} +\title{Install councilR snippets} \usage{ snippets_install(install_path = NULL, update = TRUE) } \arguments{ -\item{install_path}{character, Where should the snippets be installed? If \code{NULL}, the -snippets will install to a default path based on the current version of +\item{install_path}{character, where should the snippets be installed? If \code{NULL}, +the snippets will install to a default path based on the current version of RStudio.} -\item{update}{logical, Should existing snippets be updated in place if there are any +\item{update}{logical, should existing snippets be updated in place if there are any conflicts? Default is yes (\code{TRUE}). Otherwise, new snippets are appended to the end of the existing file, ensuring that you can recover your previous snippets by editing the snippets file.} } \description{ -Install councilR snippets -@description This function installs a set of R snippets that +This function installs a set of R snippets that are helpful when working with Metropolitan Council projects in in RStudio. By default, the snippets are installed where RStudio will find them. If you haven't previously installed snippets to RStudio, these @@ -36,8 +30,7 @@ For example, HTML snippets will not appear while editing a ".R" file, but will appear when editing a ".html" file. } \note{ -This function is adapted from -\href{https://github.com/gadenbuie/js4shiny/blob/master/R/snippets.R}{js4shiny::snippets_install()}. +This function is adapted from \href{https://github.com/gadenbuie/js4shiny/blob/main/R/snippets.R}{\code{js4shiny::snippets_install()}} } \section{Updating Existing Snippets}{ If you already have snippets installed, diff --git a/man/theme_council.Rd b/man/theme_council.Rd index 19f85a3..295a61f 100644 --- a/man/theme_council.Rd +++ b/man/theme_council.Rd @@ -50,6 +50,9 @@ The default \code{theme_council()} plus a more simple \code{theme_council_open() Please note that the y-axis text is horizontal, and long axis names will need to be wrapped; the \code{str_wrap} function from \code{stringr} will be useful. For example, consider using this piece of code: \code{labs(y = stringr::str_wrap("Axis labels are now horizontal, but you still need to insert some code to wrap long labels", width = 15))} } +\note{ +This function relies on \verb{[\{rlang\}]} internal functions. +} \section{Council fonts}{ There are a few requirements needed if you want to use Council font families. \enumerate{ diff --git a/tests/testthat/test-fetch_county_geo.R b/tests/testthat/test-fetch_county_geo.R index 6a9d491..33537f9 100644 --- a/tests/testthat/test-fetch_county_geo.R +++ b/tests/testthat/test-fetch_county_geo.R @@ -1,5 +1,3 @@ test_that("input check works", { - testthat::expect_error(fetch_county_geo(core = "foo")) - }) From d7ba78a18074359be7acd2005898968c78784a10 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 15:56:24 -0400 Subject: [PATCH 29/50] update references --- .../skeleton/references.bib | 102 ++++++++++++++---- 1 file changed, 82 insertions(+), 20 deletions(-) diff --git a/inst/rmarkdown/templates/cd-research---general/skeleton/references.bib b/inst/rmarkdown/templates/cd-research---general/skeleton/references.bib index fb8d038..210022c 100644 --- a/inst/rmarkdown/templates/cd-research---general/skeleton/references.bib +++ b/inst/rmarkdown/templates/cd-research---general/skeleton/references.bib @@ -1,37 +1,99 @@ -@Manual{CiteR, +@Manual{R-base, title = {R: A Language and Environment for Statistical Computing}, author = {{R Core Team}}, organization = {R Foundation for Statistical Computing}, address = {Vienna, Austria}, - year = {2019}, + year = {2022}, url = {https://www.R-project.org/}, - note = {Version 3.6.0}, } -@Manual{R-base, - title = {R: A Language and Environment for Statistical Computing}, - author = {{R Core Team}}, - organization = {R Foundation for Statistical Computing}, - address = {Vienna, Austria}, + +@Manual{R-citr, + title = {citr: RStudio Add-in to Insert Markdown Citations}, + author = {Frederik Aust}, year = {2019}, - url = {https://www.R-project.org/}, + note = {R package version 0.3.2}, + url = {https://github.com/crsh/citr}, +} + +@Manual{R-councilR, + title = {councilR: Functions and Templates for the Metropolitan Council}, + author = {Liz Roten}, + year = {2022}, + note = {R package version 0.1.2.9001}, +} + +@Manual{R-details, + title = {details: Create Details HTML Tag for Markdown and Package Documentation}, + author = {Jonathan Sidi}, + year = {2022}, + note = {R package version 0.3.0}, + url = {https://github.com/yonicd/details}, +} + +@Manual{R-devtools, + title = {devtools: Tools to Make Developing R Packages Easier}, + author = {Hadley Wickham and Jim Hester and Winston Chang and Jennifer Bryan}, + year = {2022}, + note = {R package version 2.4.4}, + url = {https://CRAN.R-project.org/package=devtools}, } + +@Manual{R-ggplot2, + title = {ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics}, + author = {Hadley Wickham and Winston Chang and Lionel Henry and Thomas Lin Pedersen and Kohske Takahashi and Claus Wilke and Kara Woo and Hiroaki Yutani and Dewey Dunnington}, + year = {2022}, + note = {R package version 3.3.6}, + url = {https://CRAN.R-project.org/package=ggplot2}, +} + +@Manual{R-purrr, + title = {purrr: Functional Programming Tools}, + author = {Lionel Henry and Hadley Wickham}, + year = {2020}, + note = {R package version 0.3.4}, + url = {https://CRAN.R-project.org/package=purrr}, +} + @Manual{R-repmis, title = {repmis: Miscellaneous Tools for Reproducible Research}, author = {Christopher Gandrud}, year = {2016}, note = {R package version 0.5}, - url = {https://CRAN.R-project.org/package=repmis}, + url = {http://cran.r-project.org/package=repmis}, } -@Book{dignazio_data_2020, - title = {Data {{Feminism}}}, - author = {Catherine D'Ignazio and Lauren F. Klein}, - year = {2020}, - month = {mar}, - publisher = {{The MIT Press}}, - address = {{Cambridge, Massachusetts}}, - abstract = {A new way of thinking about data science and data ethics that is informed by the ideas of intersectional feminism.Today, data science is a form of power. It has been used to expose injustice, improve health outcomes, and topple governments. But it has also been used to discriminate, police, and surveil. This potential for good, on the one hand, and harm, on the other, makes it essential to ask: Data science by whom? Data science for whom? Data science with whose interests in mind? The narratives around big data and data science are overwhelmingly white, male, and techno-heroic. In Data Feminism, Catherine D'Ignazio and Lauren Klein present a new way of thinking about data science and data ethics\rule{1em}{1pt}one that is informed by intersectional feminist thought.Illustrating data feminism in action, D'Ignazio and Klein show how challenges to the male/female binary can help challenge other hierarchical (and empirically wrong) classification systems. They explain how, for example, an understanding of emotion can expand our ideas about effective data visualization, and how the concept of invisible labor can expose the significant human efforts required by our automated systems. And they show why the data never, ever ``speak for themselves.''Data Feminism offers strategies for data scientists seeking to learn how feminism can help them work toward justice, and for feminists who want to focus their efforts on the growing field of data science. But Data Feminism is about much more than gender. It is about power, about who has it and who doesn't, and about how those differentials of power can be challenged and changed.}, - isbn = {978-0-262-04400-4}, - language = {English}, +@Manual{R-testthat, + title = {testthat: Unit Testing for R}, + author = {Hadley Wickham}, + year = {2022}, + note = {R package version 3.1.4}, + url = {https://CRAN.R-project.org/package=testthat}, +} + +@Manual{R-usethis, + title = {usethis: Automate Package and Project Setup}, + author = {Hadley Wickham and Jennifer Bryan and Malcolm Barrett}, + year = {2022}, + note = {R package version 2.1.6}, + url = {https://CRAN.R-project.org/package=usethis}, +} + +@Book{ggplot22016, + author = {Hadley Wickham}, + title = {ggplot2: Elegant Graphics for Data Analysis}, + publisher = {Springer-Verlag New York}, + year = {2016}, + isbn = {978-3-319-24277-4}, + url = {https://ggplot2.tidyverse.org}, +} + +@Article{testthat2011, + author = {Hadley Wickham}, + title = {testthat: Get Started with Testing}, + journal = {The R Journal}, + year = {2011}, + volume = {3}, + pages = {5--10}, + url = {https://journal.r-project.org/archive/2011-1/RJournal_2011-1_Wickham.pdf}, } From 66d734231ba5f025f224d0c2f0b51619df6c3467 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 15:57:28 -0400 Subject: [PATCH 30/50] update suggested questions, references --- .../skeleton/skeleton.Rmd | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/inst/rmarkdown/templates/cd-research---general/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/cd-research---general/skeleton/skeleton.Rmd index ee92853..94ef588 100644 --- a/inst/rmarkdown/templates/cd-research---general/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/cd-research---general/skeleton/skeleton.Rmd @@ -25,6 +25,10 @@ requireNamespace("details", quietly = TRUE) requireNamespace("repmis", quietly = TRUE) requireNamespace("citr", quietly = TRUE) +# install citr, if neccessary +# remotes::install_github("crsh/citr") + + library(repmis) # for package citations library(citr) # for traditional references. citr also interfaces with Zotero library(details) # reproducibility @@ -32,22 +36,11 @@ library(councilR) ## run repmis::LoadandCite() to generate references for all the packages in the environment ----- # repmis::LoadandCite(file = "references.bib") - -## repmis has a bug in handling special characters. see example below -# -# @Manual{R-dplyr, -# title = {dplyr: A Grammar of Data Manipulation}, -# author = {Hadley Wickham and Romain Fran{\c{c}}ois and Lionel Henry and Kirill M{\"{u}}ller}, -# year = {2019}, -# note = {R package version 0.8.1}, -# url = {https://CRAN.R-project.org/package=dplyr}, -# } ``` ## Background -A short introduction including metadata and project information. Include links to things like articles, data downloads, methodology, whitepapers, etc. - +A short introduction including metadata and project information. Include links to things like articles, data downloads, methodology, whitepapers, etc. Should answer questions like: What is this thing? Why does it exist? What projects are related to this one? ### Equity questions and considerations @@ -61,5 +54,10 @@ sessioninfo::session_info() ## References +```{r, message=FALSE, echo=FALSE} +knitr::write_bib(c(.packages()), "references.bib") +``` + +
From b6f5b6f6026b41d6befd37740f880e3eb47d3838 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 15:57:40 -0400 Subject: [PATCH 31/50] remove repmis; add tigris --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8c83fdc..a0167ba 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,6 +32,7 @@ Imports: rstudioapi (>= 0.11), sf (>= 0.9.5), tictoc (>= 1.0), + tigris (>= 1.6.1), utils Suggests: citr (>= 0.3.2), @@ -40,7 +41,6 @@ Suggests: details (>= 0.2.1), httr2 (>= 0.2.1), knitr (>= 1.37), - repmis (>= 0.5), rmarkdown (>= 2.11), stringr (>= 1.4.0), testthat (>= 3.0.0), From 1840209361d0ce1b8319eb7d09a03900c0080525 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 15:57:48 -0400 Subject: [PATCH 32/50] fix bug --- R/theme_council.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/theme_council.R b/R/theme_council.R index a875647..61404ec 100644 --- a/R/theme_council.R +++ b/R/theme_council.R @@ -108,9 +108,7 @@ theme_council <- function(base_size = 11, purrr::map( c( - base_size, - base_line_size, - base_rect_size, + base_size ), rlang:::check_number ) From b7071850d73d9be66e57d0b99384f2d496d7224e Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 15:57:59 -0400 Subject: [PATCH 33/50] do not eval fetch_county_geo() --- vignettes/Spatial_helpers.Rmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vignettes/Spatial_helpers.Rmd b/vignettes/Spatial_helpers.Rmd index 8d2588e..e85c4b5 100644 --- a/vignettes/Spatial_helpers.Rmd +++ b/vignettes/Spatial_helpers.Rmd @@ -57,9 +57,9 @@ regional_parks_db <- import_from_gis(query = "PARKSREGIONAL") head(regional_parks_db) ``` -A commonly fetch spatial dataset is the 7-county geography. `fetch_counties()` does just that. +A commonly fetch spatial dataset is the 7-county geography. `fetch_county_geo()` does just that. -```{r} -fetch_counties() +```{r, eval = FALSE} +fetch_county_geo() ``` From 9fd0db22478d88b194d1567ff154392c0b2540c2 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Tue, 26 Jul 2022 16:44:18 -0400 Subject: [PATCH 34/50] update link --- tests/testthat/test-utils.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index cf920bf..3f3e2f3 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,4 +1,4 @@ -## https://github.com/gadenbuie/js4shiny/blob/master/tests/testthat/test-utils.R +## https://github.com/gadenbuie/js4shiny/blob/main/tests/testthat/test-utils.R test_that("requires_pkg", { missing_pkg <- function() requires_pkg("flarf") From 4dc3e5df941b17d7c6546166b5802700a4a1c87d Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 13:50:41 -0500 Subject: [PATCH 35/50] update Noah's info --- README.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.Rmd b/README.Rmd index c6a3e38..951bdb4 100644 --- a/README.Rmd +++ b/README.Rmd @@ -39,7 +39,7 @@ Please see our contribution guidelines [here](.github/CONTRIBUTING.md). Thanks to all the folks who have contributed to this project in one way or another [@ashleyasmus](https://github.com/ashleyasmus), [@ehesch](https://github.com/ehesch), [@eroten](https://github.com/eroten), -[@svelick](https://github.com/svelick), and [@leonx075](https://github.com/leonx075). +[@velicknd](https://github.com/velicknd), and [@leonx075](https://github.com/leonx075). From db4506c802df13fafd55626ed25a80fac844495e Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 13:50:50 -0500 Subject: [PATCH 36/50] skip on cran --- tests/testthat/test-import_from_gis.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-import_from_gis.R b/tests/testthat/test-import_from_gis.R index f34734a..26ffc0c 100644 --- a/tests/testthat/test-import_from_gis.R +++ b/tests/testthat/test-import_from_gis.R @@ -1,7 +1,8 @@ # Can import_from_gis() actually import from the GISLibrary database? -# skip on GH Actions +# skip on GH Actions, CRAN testthat::skip_on_ci() +testthat::skip_on_cran() # skip if not connected to VPN testthat::skip_if( From 8ec67a636a7fe38943e445681e3f4637408af982 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 14:00:47 -0500 Subject: [PATCH 37/50] update version, date --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a0167ba..391ce7e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: councilR Title: Functions and Templates for the Metropolitan Council -Version: 0.1.2.9001 -Date: 2022-03-15 +Version: 0.1.3 +Date: 2022-08-01 Authors@R: c( person("Metropolitan Council", role = "cph"), person("Liz", "Roten", , "liz.roten@metc.state.mn.us", role = c("cre", "aut"), From 2ba0064bcf0a819f655eea3090d5421df9ca09f3 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 14:00:55 -0500 Subject: [PATCH 38/50] update Noah's info --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 716bc83..34ba530 100644 --- a/README.md +++ b/README.md @@ -33,5 +33,5 @@ or another [@ashleyasmus](https://github.com/ashleyasmus), [@ehesch](https://github.com/ehesch), [@eroten](https://github.com/eroten), -[@svelick](https://github.com/svelick), and +[@velicknd](https://github.com/velicknd), and [@leonx075](https://github.com/leonx075). From b8d79ed9f7242ec6a1011590e60426179578d534 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 14:01:16 -0500 Subject: [PATCH 39/50] reference data onboarding document --- R/import_from_emissions.R | 4 ++-- R/import_from_gis.R | 3 ++- man/import_from_emissions.Rd | 4 ++-- man/import_from_gis.Rd | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/R/import_from_emissions.R b/R/import_from_emissions.R index 5b5f081..dc146a0 100644 --- a/R/import_from_emissions.R +++ b/R/import_from_emissions.R @@ -16,8 +16,8 @@ #' @note See `vignette("Options")` to review package options. #' You must be set up with the appropriate database drivers to use this function. #' **Windows** users need ODBC with Microsoft SQL. Contact IS support for ODBC installation. -#' **Mac** users need `unixodbc` and `freetds`. See instructions in -#' [`{MetroTransitR}`](https://github.com/Metropolitan-Council/MetroTransitR) +#' **Mac** users need `unixodbc` and `freetds`. See instructions in the +#' [onboarding guide](https://furry-adventure-596f3adb.pages.github.io/database-connections.html) #' #' This function relies on `[{rlang}]` internal functions. #' diff --git a/R/import_from_gis.R b/R/import_from_gis.R index 43e05d2..96b7d21 100644 --- a/R/import_from_gis.R +++ b/R/import_from_gis.R @@ -9,7 +9,8 @@ #' @note See `vignette("Options")` to review package options. #' You must be set up with the appropriate database drivers to use this function. #' **Windows** users need ODBC with Microsoft SQL. Contact IS support for ODBC installation. -#' **Mac** users need `unixodbc` and `freetds`. See instructions in [`{MetroTransitR}`](https://github.com/Metropolitan-Council/MetroTransitR) +#' **Mac** users need `unixodbc` and `freetds`. See instructions in the [onboarding guide](https://furry-adventure-596f3adb.pages.github.io/database-connections.html) + #' #' This function relies on `[{rlang}]` internal functions. #' diff --git a/man/import_from_emissions.Rd b/man/import_from_emissions.Rd index 931b0d8..83a88ce 100644 --- a/man/import_from_emissions.Rd +++ b/man/import_from_emissions.Rd @@ -40,8 +40,8 @@ Requires a password for access to the database. See \code{vignette("Options")} to review package options. You must be set up with the appropriate database drivers to use this function. \strong{Windows} users need ODBC with Microsoft SQL. Contact IS support for ODBC installation. -\strong{Mac} users need \code{unixodbc} and \code{freetds}. See instructions in -\href{https://github.com/Metropolitan-Council/MetroTransitR}{\code{{MetroTransitR}}} +\strong{Mac} users need \code{unixodbc} and \code{freetds}. See instructions in the +\href{https://furry-adventure-596f3adb.pages.github.io/database-connections.html}{onboarding guide} \if{html}{\out{
}}\preformatted{This function relies on `[\{rlang\}]` internal functions. }\if{html}{\out{
}} diff --git a/man/import_from_gis.Rd b/man/import_from_gis.Rd index fc754c7..7a28512 100644 --- a/man/import_from_gis.Rd +++ b/man/import_from_gis.Rd @@ -31,7 +31,7 @@ Import a dataset from ArcCatalog See \code{vignette("Options")} to review package options. You must be set up with the appropriate database drivers to use this function. \strong{Windows} users need ODBC with Microsoft SQL. Contact IS support for ODBC installation. -\strong{Mac} users need \code{unixodbc} and \code{freetds}. See instructions in \href{https://github.com/Metropolitan-Council/MetroTransitR}{\code{{MetroTransitR}}} +\strong{Mac} users need \code{unixodbc} and \code{freetds}. See instructions in the \href{https://furry-adventure-596f3adb.pages.github.io/database-connections.html}{onboarding guide} \if{html}{\out{
}}\preformatted{ This function relies on `[\{rlang\}]` internal functions. }\if{html}{\out{
}} From dd0f4db675a628a0afdbf8299442cf71b83eb2ee Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 14:09:25 -0500 Subject: [PATCH 40/50] remove council_theme() --- NAMESPACE | 3 - R/council_theme.R | 145 ---------------------------------------------- 2 files changed, 148 deletions(-) delete mode 100644 R/council_theme.R diff --git a/NAMESPACE b/NAMESPACE index 5c8c2d9..b80afe9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,7 +3,6 @@ export("%>%") export(council.pal) export(council_pal2) -export(council_theme) export(fetch_county_geo) export(import_from_emissions) export(import_from_gis) @@ -35,7 +34,6 @@ importFrom(ggplot2,element_text) importFrom(ggplot2,margin) importFrom(ggplot2,rel) importFrom(ggplot2,theme) -importFrom(ggplot2,theme_minimal) importFrom(ggplot2,unit) importFrom(glue,glue) importFrom(magrittr,"%>%") @@ -44,7 +42,6 @@ importFrom(purrr,flatten) importFrom(purrr,map) importFrom(purrr,map_depth) importFrom(purrr,reduce) -importFrom(rlang,warn) importFrom(sf,read_sf) importFrom(sf,st_as_sf) importFrom(sf,st_transform) diff --git a/R/council_theme.R b/R/council_theme.R deleted file mode 100644 index a9dcec2..0000000 --- a/R/council_theme.R +++ /dev/null @@ -1,145 +0,0 @@ -#' @title Council ggplot2 theme -#' -#' @param use_showtext Logical, whether to use Council fonts. -#' @param size_header Header font size in pt. Default is 22 -#' @param size_axis_title Axis title font size in pt. Default is 14. -#' @param size_legend_title Legend title font size in pt. Default is 14. -#' @param size_axis_text Axis text font size in pt. Default is 11 -#' @param size_legend_text Legend test font size in pt. Default is 10. -#' @param size_caption Caption font size in pt. Default is 8. -#' @param size_margin Margin size in pt. Default is 10 -#' -#' -#' @details -#' # Council fonts -#' -#' There are a few requirements needed if you want to use Council font families. -#' -#' 1. You must have the optional [`{showtext}`](https://github.com/yixuan/showtext) -#' and [`{sysfonts}`](https://github.com/yixuan/sysfonts) packages installed. -#' -#' 2. You must have the following fonts installed: -#' - HelveticaNeueLT Standard Light, Standard Condensed, and Standard Medium Condensed -#' - Arial Narrow -#' - Palatino Linotype -#' If you do not have the font files handy, contact a package author or your manager. -#' -#' 3. The font family and file names much match those listed below -#' - "HelveticaNeueLT Std Cn" = "HelveticaNeueLTStd-Cn.otf" -#' - "HelveticaNeueLT Std Lt" = "HelveticaNeueLTStd-Lt.otf" -#' - "Arial Narrow" ="ARIALN.TTF" -#' - "HelveticaNeueLT Std Med Cn" = "HelveticaNeueLTStd-MdCn.otf") -#' - "Palatino Linotype" = "pala.ttf" -#' -#' 4. Consider options for your OS -#' - On Windows, be sure that the fonts are installed for the entire system, not just a single user. -#' These are located in `C:/Windows/Fonts`. -#' - On Mac OSX, be sure that fonts are installed for the user. These are located in `~/Library/Fonts`. -#' Consider copying the entire system font directory (`/Library/Fonts`) to the user font directory for easy access. -#' -#' # Font size suggestions -#' If you are creating plots for a presentation, you should increase all font sizes. -#' Check the default font sizes in the presentation platform you are working in -#' and adjust from there. For example, Microsoft PowerPoint sets slide headings at 77 pnt and -#' body text at 46 pnt. You will likely want to make the plot title less than 77 pnt so you -#' can preserve the text hierarchy in the slide. -#' -#' # Theme modifications -#' If you wish to make changes to this theme template, such as removing -#' the legend, adjusting text positions, access the source code by typing -#' `councilR::council_theme` in the console. You can then copy/paste the -#' function into whatever document you are working on and make changes there. -#' If you want to make a change to the default template, open an Issue on GitHub -#' and ask for the change to be made, and/or make the change yourself and make -#' a pull request. -#' -#' -#' @return a [ggplot2::theme()] object -#' @export -#' -#' @family aesthetics -#' -#' @importFrom ggplot2 theme_minimal theme element_text margin -#' @importFrom rlang warn -#' -council_theme <- function(use_showtext = FALSE, - size_header = 22, - size_axis_title = 14, - size_legend_title = 14, - size_axis_text = 11, - size_legend_text = 10, - size_caption = 8, - size_margin = 10) { - rlang::warn(message = "council_theme() is deprecated as of version 0.1.1. Please use theme_council()", .frequency = "once", .frequency_id = "once") - - if (use_showtext == TRUE) { - requireNamespace("sysfonts", quietly = TRUE) - requireNamespace("showtext", quietly = TRUE) - - showtext::showtext_auto() - sysfonts::font_paths() - files <- sysfonts::font_files() - sysfonts::font_add("HelveticaNeueLT Std Cn", "HelveticaNeueLTStd-Cn.otf") - sysfonts::font_add("HelveticaNeueLT Std Lt", "HelveticaNeueLTStd-Lt.otf") - sysfonts::font_add("Arial Narrow", "ARIALN.TTF") - sysfonts::font_add("HelveticaNeueLT Std Med Cn", "HelveticaNeueLTStd-MdCn.otf") - sysfonts::font_add("Palatino Linotype", "pala.ttf") - - - font_title <- "HelveticaNeueLT Std Lt" - font_caption <- "Palatino Linotype" - font_axis <- "Arial Narrow" - } else { - font_title <- "sans" - font_caption <- "serif" - font_axis <- "sans" - } - - - ggplot2::theme_minimal() + - ggplot2::theme( - plot.margin = ggplot2::margin(size_margin, size_margin, size_margin, size_margin, "pt"), - axis.title.x = ggplot2::element_text( - vjust = -1, - family = font_axis, - size = size_axis_title - ), - axis.title.y = ggplot2::element_text( - vjust = 2, - family = font_axis, - size = size_axis_title - ), - axis.text.x = ggplot2::element_text( - family = font_axis, - size = size_axis_text, - vjust = 0.5 - ), - axis.text.y = ggplot2::element_text( - family = font_axis, - size = size_axis_text, - vjust = 1 - ), - plot.caption = ggplot2::element_text( - family = font_caption, - hjust = 1, - size = size_caption - ), - plot.title = ggplot2::element_text( - family = font_title, - # hjust = 0.5, - size = size_header - ), - legend.title = ggplot2::element_text( - family = font_title, - size = size_legend_title - ), - legend.text = ggplot2::element_text( - family = font_axis, - size = size_legend_text, - ), - strip.text.x = ggplot2::element_text( - family = font_axis, - size = size_axis_title - ) - ) -} From 72284a7c41b4d223bb4fa9d9a05fafa55a7ad31c Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 14:09:35 -0500 Subject: [PATCH 41/50] make sf a URL --- R/import_from_gis.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/import_from_gis.R b/R/import_from_gis.R index 96b7d21..82e254c 100644 --- a/R/import_from_gis.R +++ b/R/import_from_gis.R @@ -14,7 +14,7 @@ #' #' This function relies on `[{rlang}]` internal functions. #' -#' @return an `sf` object +#' @return an [`sf`]() object #' @export #' @examples \dontrun{ #' library(councilR) From 4d24907654bf21e9336e24f7e4d39fed9daf84d6 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 14:09:55 -0500 Subject: [PATCH 42/50] Update docs --- R/theme_council.R | 12 ++--- man/blue_cascade.Rd | 1 - man/colors.Rd | 1 - man/council.pal.Rd | 1 - man/council_pal2.Rd | 1 - man/council_theme.Rd | 103 ------------------------------------- man/import_from_gis.Rd | 2 +- man/scale_color_council.Rd | 1 - man/scale_fill_council.Rd | 1 - man/theme_council.Rd | 10 ++-- 10 files changed, 12 insertions(+), 121 deletions(-) delete mode 100644 man/council_theme.Rd diff --git a/R/theme_council.R b/R/theme_council.R index 61404ec..b4f1b26 100644 --- a/R/theme_council.R +++ b/R/theme_council.R @@ -1,16 +1,17 @@ #' @title Council ggplot2 theme #' -#' @description The default `theme_council()` plus a more simple `theme_council_open()` for making MetCouncil figures. `theme_council()` will be appropriate in most cases while `theme_council_open()` is appropriate for single scatterplots or line graphs. +#' @description The default `theme_council()` plus a more simple `theme_council_open()` for making MetCouncil figures. `theme_council()` will be appropriate in most cases while `theme_council_open()` is appropriate for single scatter plots or line graphs. #' -#' Please note that the y-axis text is horizontal, and long axis names will need to be wrapped; the `str_wrap` function from `stringr` will be useful. For example, consider using this piece of code: `labs(y = stringr::str_wrap("Axis labels are now horizontal, but you still need to insert some code to wrap long labels", width = 15))` +#' Please note that the y-axis text is horizontal, and long axis names will need to be wrapped; [`stringr::str_wrap()`]() is useful for managing length. +#' For example, consider using this piece of code: `labs(y = stringr::str_wrap("Axis labels are now horizontal, but you still need to insert some code to wrap long labels", width = 15))` #' #' @param base_size numeric, base font size, given in pts. Default is `11` #' @param base_family character, base font family. Default is `""` #' @param base_line_size numeric, base size for line elements. Default is `base_size/22` -#' @param base_rect_size numeric, base size for rect elements. Default is `base_size/22` +#' @param base_rect_size numeric, base size for `rect` elements. Default is `base_size/22` #' @param use_showtext logical, whether to use Council fonts. #' @param use_manual_font_sizes logical, use supplied font sizes. -#' @param font_sizes named list of font sizes. Only used if `use_manual_font_sizes` is `TRUE` +#' @param font_sizes named list, font sizes. Only used if `use_manual_font_sizes` is `TRUE` #' #' @return a [ggplot2::theme()] object #' @export @@ -415,8 +416,7 @@ theme_council <- function(base_size = 11, #' @rdname theme_council #' @export - - +#' theme_council_open <- function(base_size = 11, base_family = "", base_line_size = base_size / 22, diff --git a/man/blue_cascade.Rd b/man/blue_cascade.Rd index 50594c4..e2aa439 100644 --- a/man/blue_cascade.Rd +++ b/man/blue_cascade.Rd @@ -40,7 +40,6 @@ Other aesthetics: \code{\link{colors}}, \code{\link{council.pal}()}, \code{\link{council_pal2}()}, -\code{\link{council_theme}()}, \code{\link{scale_color_council}()}, \code{\link{scale_fill_council}()}, \code{\link{theme_council}()} diff --git a/man/colors.Rd b/man/colors.Rd index aca75e6..956cb93 100644 --- a/man/colors.Rd +++ b/man/colors.Rd @@ -58,7 +58,6 @@ Other aesthetics: \code{\link{blue_cascade}}, \code{\link{council.pal}()}, \code{\link{council_pal2}()}, -\code{\link{council_theme}()}, \code{\link{scale_color_council}()}, \code{\link{scale_fill_council}()}, \code{\link{theme_council}()} diff --git a/man/council.pal.Rd b/man/council.pal.Rd index acda60d..fd2cb44 100644 --- a/man/council.pal.Rd +++ b/man/council.pal.Rd @@ -31,7 +31,6 @@ Other aesthetics: \code{\link{blue_cascade}}, \code{\link{colors}}, \code{\link{council_pal2}()}, -\code{\link{council_theme}()}, \code{\link{scale_color_council}()}, \code{\link{scale_fill_council}()}, \code{\link{theme_council}()} diff --git a/man/council_pal2.Rd b/man/council_pal2.Rd index 805df33..0767710 100644 --- a/man/council_pal2.Rd +++ b/man/council_pal2.Rd @@ -18,7 +18,6 @@ Other aesthetics: \code{\link{blue_cascade}}, \code{\link{colors}}, \code{\link{council.pal}()}, -\code{\link{council_theme}()}, \code{\link{scale_color_council}()}, \code{\link{scale_fill_council}()}, \code{\link{theme_council}()} diff --git a/man/council_theme.Rd b/man/council_theme.Rd deleted file mode 100644 index c418e5b..0000000 --- a/man/council_theme.Rd +++ /dev/null @@ -1,103 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/council_theme.R -\name{council_theme} -\alias{council_theme} -\title{Council ggplot2 theme} -\usage{ -council_theme( - use_showtext = FALSE, - size_header = 22, - size_axis_title = 14, - size_legend_title = 14, - size_axis_text = 11, - size_legend_text = 10, - size_caption = 8, - size_margin = 10 -) -} -\arguments{ -\item{use_showtext}{Logical, whether to use Council fonts.} - -\item{size_header}{Header font size in pt. Default is 22} - -\item{size_axis_title}{Axis title font size in pt. Default is 14.} - -\item{size_legend_title}{Legend title font size in pt. Default is 14.} - -\item{size_axis_text}{Axis text font size in pt. Default is 11} - -\item{size_legend_text}{Legend test font size in pt. Default is 10.} - -\item{size_caption}{Caption font size in pt. Default is 8.} - -\item{size_margin}{Margin size in pt. Default is 10} -} -\value{ -a \code{\link[ggplot2:theme]{ggplot2::theme()}} object -} -\description{ -Council ggplot2 theme -} -\section{Council fonts}{ -There are a few requirements needed if you want to use Council font families. -\enumerate{ -\item You must have the optional \href{https://github.com/yixuan/showtext}{\code{{showtext}}} -and \href{https://github.com/yixuan/sysfonts}{\code{{sysfonts}}} packages installed. -\item You must have the following fonts installed: -} -\itemize{ -\item HelveticaNeueLT Standard Light, Standard Condensed, and Standard Medium Condensed -\item Arial Narrow -\item Palatino Linotype -If you do not have the font files handy, contact a package author or your manager. -} -\enumerate{ -\item The font family and file names much match those listed below -} -\itemize{ -\item "HelveticaNeueLT Std Cn" = "HelveticaNeueLTStd-Cn.otf" -\item "HelveticaNeueLT Std Lt" = "HelveticaNeueLTStd-Lt.otf" -\item "Arial Narrow" ="ARIALN.TTF" -\item "HelveticaNeueLT Std Med Cn" = "HelveticaNeueLTStd-MdCn.otf") -\item "Palatino Linotype" = "pala.ttf" -} -\enumerate{ -\item Consider options for your OS -} -\itemize{ -\item On Windows, be sure that the fonts are installed for the entire system, not just a single user. -These are located in \verb{C:/Windows/Fonts}. -\item On Mac OSX, be sure that fonts are installed for the user. These are located in \verb{~/Library/Fonts}. -Consider copying the entire system font directory (\verb{/Library/Fonts}) to the user font directory for easy access. -} -} - -\section{Font size suggestions}{ -If you are creating plots for a presentation, you should increase all font sizes. -Check the default font sizes in the presentation platform you are working in -and adjust from there. For example, Microsoft PowerPoint sets slide headings at 77 pnt and -body text at 46 pnt. You will likely want to make the plot title less than 77 pnt so you -can preserve the text hierarchy in the slide. -} - -\section{Theme modifications}{ -If you wish to make changes to this theme template, such as removing -the legend, adjusting text positions, access the source code by typing -\code{councilR::council_theme} in the console. You can then copy/paste the -function into whatever document you are working on and make changes there. -If you want to make a change to the default template, open an Issue on GitHub -and ask for the change to be made, and/or make the change yourself and make -a pull request. -} - -\seealso{ -Other aesthetics: -\code{\link{blue_cascade}}, -\code{\link{colors}}, -\code{\link{council.pal}()}, -\code{\link{council_pal2}()}, -\code{\link{scale_color_council}()}, -\code{\link{scale_fill_council}()}, -\code{\link{theme_council}()} -} -\concept{aesthetics} diff --git a/man/import_from_gis.Rd b/man/import_from_gis.Rd index 7a28512..d208015 100644 --- a/man/import_from_gis.Rd +++ b/man/import_from_gis.Rd @@ -22,7 +22,7 @@ Must match the database name in \code{query}.} \item{pwd}{character, user password. Default is \code{getOption("councilR.pwd")}.} } \value{ -an \code{sf} object +an \url{sf} object } \description{ Import a dataset from ArcCatalog diff --git a/man/scale_color_council.Rd b/man/scale_color_council.Rd index 020cf38..ccfd8ff 100644 --- a/man/scale_color_council.Rd +++ b/man/scale_color_council.Rd @@ -35,7 +35,6 @@ Other aesthetics: \code{\link{colors}}, \code{\link{council.pal}()}, \code{\link{council_pal2}()}, -\code{\link{council_theme}()}, \code{\link{scale_fill_council}()}, \code{\link{theme_council}()} } diff --git a/man/scale_fill_council.Rd b/man/scale_fill_council.Rd index 3a61550..8dfff49 100644 --- a/man/scale_fill_council.Rd +++ b/man/scale_fill_council.Rd @@ -31,7 +31,6 @@ Other aesthetics: \code{\link{colors}}, \code{\link{council.pal}()}, \code{\link{council_pal2}()}, -\code{\link{council_theme}()}, \code{\link{scale_color_council}()}, \code{\link{theme_council}()} } diff --git a/man/theme_council.Rd b/man/theme_council.Rd index 295a61f..45f874a 100644 --- a/man/theme_council.Rd +++ b/man/theme_council.Rd @@ -34,21 +34,22 @@ theme_council_open( \item{base_line_size}{numeric, base size for line elements. Default is \code{base_size/22}} -\item{base_rect_size}{numeric, base size for rect elements. Default is \code{base_size/22}} +\item{base_rect_size}{numeric, base size for \code{rect} elements. Default is \code{base_size/22}} \item{use_showtext}{logical, whether to use Council fonts.} \item{use_manual_font_sizes}{logical, use supplied font sizes.} -\item{font_sizes}{named list of font sizes. Only used if \code{use_manual_font_sizes} is \code{TRUE}} +\item{font_sizes}{named list, font sizes. Only used if \code{use_manual_font_sizes} is \code{TRUE}} } \value{ a \code{\link[ggplot2:theme]{ggplot2::theme()}} object } \description{ -The default \code{theme_council()} plus a more simple \code{theme_council_open()} for making MetCouncil figures. \code{theme_council()} will be appropriate in most cases while \code{theme_council_open()} is appropriate for single scatterplots or line graphs. +The default \code{theme_council()} plus a more simple \code{theme_council_open()} for making MetCouncil figures. \code{theme_council()} will be appropriate in most cases while \code{theme_council_open()} is appropriate for single scatter plots or line graphs. -Please note that the y-axis text is horizontal, and long axis names will need to be wrapped; the \code{str_wrap} function from \code{stringr} will be useful. For example, consider using this piece of code: \code{labs(y = stringr::str_wrap("Axis labels are now horizontal, but you still need to insert some code to wrap long labels", width = 15))} +Please note that the y-axis text is horizontal, and long axis names will need to be wrapped; \url{stringr::str_wrap()} is useful for managing length. +For example, consider using this piece of code: \code{labs(y = stringr::str_wrap("Axis labels are now horizontal, but you still need to insert some code to wrap long labels", width = 15))} } \note{ This function relies on \verb{[\{rlang\}]} internal functions. @@ -130,7 +131,6 @@ Other aesthetics: \code{\link{colors}}, \code{\link{council.pal}()}, \code{\link{council_pal2}()}, -\code{\link{council_theme}()}, \code{\link{scale_color_council}()}, \code{\link{scale_fill_council}()} } From 40defeec5c03d26f13d4f640a576e7202c667112 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 14:17:07 -0500 Subject: [PATCH 43/50] update docs --- R/fetch_county_geo.R | 5 +++-- R/import_from_emissions.R | 1 + R/import_from_gis.R | 2 +- R/import_from_gpkg.R | 6 +++--- R/scale_fill_council.R | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/R/fetch_county_geo.R b/R/fetch_county_geo.R index 0dbca4d..f5f5934 100644 --- a/R/fetch_county_geo.R +++ b/R/fetch_county_geo.R @@ -1,8 +1,9 @@ #' @title Fetch standardized county geography #' -#' @param core logical, whether to include all counties in the MPO. +#' @param core logical, whether to include all counties in the MPO. Default is `TRUE`. #' @param ... Arguments passed to `[tigris::counties]` -#' @return An `[sf]` object containing the +#' +#' @return An [`sf`] object containing county geographies. #' @export #' @family spatial helpers #' @examples diff --git a/R/import_from_emissions.R b/R/import_from_emissions.R index dc146a0..42dd1c1 100644 --- a/R/import_from_emissions.R +++ b/R/import_from_emissions.R @@ -9,6 +9,7 @@ #' Default is `"dbsqlcl11t.test.local,65414"` (the test database). #' @param db character, database name. Default is `"CD_Emissions"` #' @param local logical, whether to pull from the onsite database or Azure. +#' Default is `TRUE` #' #' @description WARNING: Function error may results in RStudio crash. #' Requires a password for access to the database. diff --git a/R/import_from_gis.R b/R/import_from_gis.R index 82e254c..5e0b123 100644 --- a/R/import_from_gis.R +++ b/R/import_from_gis.R @@ -14,7 +14,7 @@ #' #' This function relies on `[{rlang}]` internal functions. #' -#' @return an [`sf`]() object +#' @return an [`sf`] object #' @export #' @examples \dontrun{ #' library(councilR) diff --git a/R/import_from_gpkg.R b/R/import_from_gpkg.R index 2ced34e..302d75d 100644 --- a/R/import_from_gpkg.R +++ b/R/import_from_gpkg.R @@ -1,4 +1,4 @@ -#' @title Import an `sf` object using a URL +#' @title Import an `sf` object using a geopackage URL #' #' @param link character, URL for the `.gpkg` object #' @param save_file logical, whether to save the downloaded file. @@ -9,9 +9,9 @@ #' Default is `4326` (WGS 84) #' @param keep_temp character, whether to keep the temporary download. #' Default is `FALSE`. -#' @param .quiet logical, suppress messages +#' @param .quiet logical, suppress messages. Default is `TRUE`. #' -#' @return an `sf` object +#' @return an [`sf`] object #' @export #' #' @description Particularly useful for importing data from Minnesota Geospatial Commons diff --git a/R/scale_fill_council.R b/R/scale_fill_council.R index 1032c5f..c7bf62f 100644 --- a/R/scale_fill_council.R +++ b/R/scale_fill_council.R @@ -1,5 +1,5 @@ -#' @title Council colors turned into palettes -#' @description `scale_color_council()` and `scale_fill_council` will give +#' @title Council colors as palettes +#' @description `scale_color_council()` and `scale_fill_council` give #' a color palette starting with `councilBlue`, followed by `cdGreen` and `mtsRed`, #' and then a couple other Council colors which will look #' decent afterwards (up to 8 levels). From 3bd142fc0089d0b88838d62f18399677ae0ac244 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 14:17:12 -0500 Subject: [PATCH 44/50] document all --- man/council.pal.Rd | 4 ++-- man/fetch_county_geo.Rd | 4 ++-- man/import_from_emissions.Rd | 3 ++- man/import_from_gis.Rd | 2 +- man/import_from_gpkg.Rd | 6 +++--- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/man/council.pal.Rd b/man/council.pal.Rd index fd2cb44..8c9c05e 100644 --- a/man/council.pal.Rd +++ b/man/council.pal.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/scale_fill_council.R \name{council.pal} \alias{council.pal} -\title{Council colors turned into palettes} +\title{Council colors as palettes} \usage{ council.pal(n, name) } @@ -12,7 +12,7 @@ council.pal(n, name) \item{name}{character, starting color name. One of \code{councilR::colors}.} } \description{ -\code{scale_color_council()} and \code{scale_fill_council} will give +\code{scale_color_council()} and \code{scale_fill_council} give a color palette starting with \code{councilBlue}, followed by \code{cdGreen} and \code{mtsRed}, and then a couple other Council colors which will look decent afterwards (up to 8 levels). diff --git a/man/fetch_county_geo.Rd b/man/fetch_county_geo.Rd index 94b6815..bb7ba01 100644 --- a/man/fetch_county_geo.Rd +++ b/man/fetch_county_geo.Rd @@ -7,12 +7,12 @@ fetch_county_geo(core = TRUE, ...) } \arguments{ -\item{core}{logical, whether to include all counties in the MPO.} +\item{core}{logical, whether to include all counties in the MPO. Default is \code{TRUE}.} \item{...}{Arguments passed to \verb{[tigris::counties]}} } \value{ -An \verb{[sf]} object containing the +An \code{\link{sf}} object containing county geographies. } \description{ Fetch standardized county geography diff --git a/man/import_from_emissions.Rd b/man/import_from_emissions.Rd index 83a88ce..a7ac5b4 100644 --- a/man/import_from_emissions.Rd +++ b/man/import_from_emissions.Rd @@ -22,7 +22,8 @@ Default is \code{getOption("councilR.uid")}. For example, \code{"mc\\\\rotenle"} \item{pwd}{character, your network password. Default is \code{getOption("councilR.pwd")}. For example, \code{"my_password"}} -\item{local}{logical, whether to pull from the onsite database or Azure.} +\item{local}{logical, whether to pull from the onsite database or Azure. +Default is \code{TRUE}} \item{serv}{character, database server. Default is \code{"dbsqlcl11t.test.local,65414"} (the test database).} diff --git a/man/import_from_gis.Rd b/man/import_from_gis.Rd index d208015..517b6c3 100644 --- a/man/import_from_gis.Rd +++ b/man/import_from_gis.Rd @@ -22,7 +22,7 @@ Must match the database name in \code{query}.} \item{pwd}{character, user password. Default is \code{getOption("councilR.pwd")}.} } \value{ -an \url{sf} object +an \code{\link{sf}} object } \description{ Import a dataset from ArcCatalog diff --git a/man/import_from_gpkg.Rd b/man/import_from_gpkg.Rd index 3fb27ae..842e52e 100644 --- a/man/import_from_gpkg.Rd +++ b/man/import_from_gpkg.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/import_from_gpkg.R \name{import_from_gpkg} \alias{import_from_gpkg} -\title{Import an \code{sf} object using a URL} +\title{Import an \code{sf} object using a geopackage URL} \usage{ import_from_gpkg( link, @@ -28,10 +28,10 @@ Default is \code{4326} (WGS 84)} \item{keep_temp}{character, whether to keep the temporary download. Default is \code{FALSE}.} -\item{.quiet}{logical, suppress messages} +\item{.quiet}{logical, suppress messages. Default is \code{TRUE}.} } \value{ -an \code{sf} object +an \code{\link{sf}} object } \description{ Particularly useful for importing data from Minnesota Geospatial Commons From 61f0a68fbc121cba3b5189493d8f4e46eca4f58a Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 14:25:46 -0500 Subject: [PATCH 45/50] add council_theme with rlang::abort() --- NAMESPACE | 2 ++ R/d_council_theme.R | 28 +++++++++++++++++++ man/council_theme.Rd | 40 +++++++++++++++++++++++++++ tests/testthat/test-d_council_theme.R | 5 ++++ 4 files changed, 75 insertions(+) create mode 100644 R/d_council_theme.R create mode 100644 man/council_theme.Rd create mode 100644 tests/testthat/test-d_council_theme.R diff --git a/NAMESPACE b/NAMESPACE index b80afe9..e40d670 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ export("%>%") export(council.pal) export(council_pal2) +export(council_theme) export(fetch_county_geo) export(import_from_emissions) export(import_from_gis) @@ -42,6 +43,7 @@ importFrom(purrr,flatten) importFrom(purrr,map) importFrom(purrr,map_depth) importFrom(purrr,reduce) +importFrom(rlang,abort) importFrom(sf,read_sf) importFrom(sf,st_as_sf) importFrom(sf,st_transform) diff --git a/R/d_council_theme.R b/R/d_council_theme.R new file mode 100644 index 0000000..d35d121 --- /dev/null +++ b/R/d_council_theme.R @@ -0,0 +1,28 @@ +#' @title DEPRECATED Council ggplot2 theme +#' +#' @param use_showtext Logical, whether to use Council fonts. +#' @param size_header Header font size in pt. Default is 22 +#' @param size_axis_title Axis title font size in pt. Default is 14. +#' @param size_legend_title Legend title font size in pt. Default is 14. +#' @param size_axis_text Axis text font size in pt. Default is 11 +#' @param size_legend_text Legend test font size in pt. Default is 10. +#' @param size_caption Caption font size in pt. Default is 8. +#' @param size_margin Margin size in pt. Default is 10 +#' +#' +#' @return an error +#' @export +#' +#' @importFrom rlang abort +#' +council_theme <- function(use_showtext = FALSE, + size_header = 22, + size_axis_title = 14, + size_legend_title = 14, + size_axis_text = 11, + size_legend_text = 10, + size_caption = 8, + size_margin = 10) { + rlang::abort(message = "council_theme() is deprecated as of version 0.1.1. Please use theme_council()") + +} diff --git a/man/council_theme.Rd b/man/council_theme.Rd new file mode 100644 index 0000000..c57b9c8 --- /dev/null +++ b/man/council_theme.Rd @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/d_council_theme.R +\name{council_theme} +\alias{council_theme} +\title{DEPRECATED Council ggplot2 theme} +\usage{ +council_theme( + use_showtext = FALSE, + size_header = 22, + size_axis_title = 14, + size_legend_title = 14, + size_axis_text = 11, + size_legend_text = 10, + size_caption = 8, + size_margin = 10 +) +} +\arguments{ +\item{use_showtext}{Logical, whether to use Council fonts.} + +\item{size_header}{Header font size in pt. Default is 22} + +\item{size_axis_title}{Axis title font size in pt. Default is 14.} + +\item{size_legend_title}{Legend title font size in pt. Default is 14.} + +\item{size_axis_text}{Axis text font size in pt. Default is 11} + +\item{size_legend_text}{Legend test font size in pt. Default is 10.} + +\item{size_caption}{Caption font size in pt. Default is 8.} + +\item{size_margin}{Margin size in pt. Default is 10} +} +\value{ +an error +} +\description{ +DEPRECATED Council ggplot2 theme +} diff --git a/tests/testthat/test-d_council_theme.R b/tests/testthat/test-d_council_theme.R new file mode 100644 index 0000000..03f95a7 --- /dev/null +++ b/tests/testthat/test-d_council_theme.R @@ -0,0 +1,5 @@ +test_that("function aborts", { + testthat::expect_error( + council_theme() + ) +}) From f7953449731040a5c7c643b49129d5fdd93dc795 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 14:33:44 -0500 Subject: [PATCH 46/50] make error message more helpful --- R/d_council_theme.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/d_council_theme.R b/R/d_council_theme.R index d35d121..e2a747f 100644 --- a/R/d_council_theme.R +++ b/R/d_council_theme.R @@ -23,6 +23,8 @@ council_theme <- function(use_showtext = FALSE, size_legend_text = 10, size_caption = 8, size_margin = 10) { - rlang::abort(message = "council_theme() is deprecated as of version 0.1.1. Please use theme_council()") + rlang::abort( + message = "council_theme() is deprecated as of version 0.1.1. Please use theme_council()", + body = c("Equivalent is `theme_council(use_showtext = FALSE, use_manual_font_sizes = TRUE)`")) } From 6a7e481158565e90716655a952c27b0e9945607c Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 16:03:05 -0500 Subject: [PATCH 47/50] update styling --- R/d_council_theme.R | 4 ++-- vignettes/Spatial_helpers.Rmd | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/R/d_council_theme.R b/R/d_council_theme.R index e2a747f..05f95ca 100644 --- a/R/d_council_theme.R +++ b/R/d_council_theme.R @@ -25,6 +25,6 @@ council_theme <- function(use_showtext = FALSE, size_margin = 10) { rlang::abort( message = "council_theme() is deprecated as of version 0.1.1. Please use theme_council()", - body = c("Equivalent is `theme_council(use_showtext = FALSE, use_manual_font_sizes = TRUE)`")) - + body = c("Equivalent is `theme_council(use_showtext = FALSE, use_manual_font_sizes = TRUE)`") + ) } diff --git a/vignettes/Spatial_helpers.Rmd b/vignettes/Spatial_helpers.Rmd index e85c4b5..374b5f3 100644 --- a/vignettes/Spatial_helpers.Rmd +++ b/vignettes/Spatial_helpers.Rmd @@ -20,7 +20,8 @@ library(councilR) `{councilR}` has a couple functions and snippets to help you access and manipulate spatial data. -## Snippets +## Snippets + Once you have installed snippets using `councilR::snippets_install()`, you will now have important values quickly accessible. To access them, start typing the snippet name into the console. The snippet will autocomplete. - `metro_crs`, the numeric preferred coordinate reference system (CRS) for our region. Most commonly used when transforming a spatial object's projection with `sf::st_transform(df, 26915)` @@ -40,7 +41,7 @@ metro_centroid ## Functions -Some datasets are maintained on [Minnesota Geospatial Commons](https://gisdata.mn.gov/). These datasets generally mirror datasets available in the internal GISLibrary. On Minnesota Geospatial commons, navigate to the dataset you want to access. Find the button to download the OGC GeoPackage format, and right click on it. Select "Copy link address". The address will end with ".zip". +Some datasets are maintained on [Minnesota Geospatial Commons](https://gisdata.mn.gov/). These datasets generally mirror datasets available in the internal GISLibrary. On Minnesota Geospatial commons, navigate to the dataset you want to access. Find the button to download the OGC GeoPackage format, and right click on it. Select "Copy link address". The address will end with ".zip". Pass this link to `import_from_gpkg()` to get the [sf]() object! @@ -57,9 +58,9 @@ regional_parks_db <- import_from_gis(query = "PARKSREGIONAL") head(regional_parks_db) ``` + A commonly fetch spatial dataset is the 7-county geography. `fetch_county_geo()` does just that. ```{r, eval = FALSE} fetch_county_geo() ``` - From 8c11011499bb65146b9095890a0d864ad7b019b5 Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 16:03:15 -0500 Subject: [PATCH 48/50] re-save colors --- data-raw/colors.R | 4 ---- data/blue_cascade.rda | Bin 244 -> 244 bytes data/colors.rda | Bin 472 -> 472 bytes 3 files changed, 4 deletions(-) diff --git a/data-raw/colors.R b/data-raw/colors.R index 70cd55e..66b5774 100644 --- a/data-raw/colors.R +++ b/data-raw/colors.R @@ -2,7 +2,6 @@ colors <- list( - ## Council and Metro Transit Colors councilBlue = "#0054A4", # Council blue cdGreen = "#78A22F", # Community Development green @@ -77,9 +76,6 @@ blue_cascade <- list( ) ) - - - # wow, what great colors usethis::use_data(colors, overwrite = TRUE, compress = "xz") usethis::use_data(blue_cascade, overwrite = TRUE, compress = "xz") diff --git a/data/blue_cascade.rda b/data/blue_cascade.rda index f80d6d627ff1d67adf841ddf40663adbfacc774c..8058ff2e9db2e146988514c4bd95b76ffadb62c5 100644 GIT binary patch delta 186 zcmV;r07d`w0rUZoEq^#VU?w5A59C0uH$#y+MEJyoIh~FtwsjphTy&G9q*k?*x3;9# z%<%-3Qoz5!V|_x?E03_|l9Ncdbh7>EA`8Cb`O$B@eWx+Qp7{xLoYT<#$A}lL3A<+s zWm>NDQQp^Nxo|tKf5RC^IEXu(*NE9RNhb@f>Fmev24Ak?bub`lqO|I2LLMp`g{@$& o_eO%0g)7Lv=g-Qw|Bbc#mKaj|okLDZm8Q*$fB+d$?Z}bb80k)7xc~qF delta 186 zcmV;r07d`w0rUZoEq^SGe%k0$CnR29WwG<~Ae?0!0YnRf^q)NR>*pBW2nIy!fKB@5 zDuSJXCFefZAdT81|7A)9FZR@gr9~HMBYwUUcm{DrY=RjUl$-RCvEG)8+f&W8QN> zOIPi(kQikOp6}2>u88&WEJ&Plf6tEx*Ltdyqh_3_eh}HH<8v@U)r5hY5rb~i)Z#ol zTz(O~G<2J&b%)q*qi?mrb5#E8^l@QI-^k3@;e4Fz6xv|^pFX+kvqyhCzys&feE}-% zwNq+@$H!Uw=zlHzQ8)dbdOggcpHe0Qy@q>MVC6?iaN}>*=nTO;r!C&E0ew|{ExxO_E=P7*CxAkC>R z^xK#grbn*W(Yn zyR?`;S;J_DYhP+*>L1qLUcB$Ooc5s+wb5pzZ%q~(U`ceH^OkFj_u3WG?GNdTHbLd( zubeNGSyaI5Wq*$V7EB&XKiUkpg1o)3P};gpz6ujFBx+0VKTdqsL>n%Os7Io>pCSIC z9HDFa7DVLoV|K~ Date: Mon, 1 Aug 2022 16:06:28 -0500 Subject: [PATCH 49/50] update license year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 9987fbc..33374d0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,2 @@ -YEAR: 2021 +YEAR: 2022 COPYRIGHT HOLDER: Metropolitan Council From 6427539482de78cb2b3e173223633f0b927f7beb Mon Sep 17 00:00:00 2001 From: Liz Roten Date: Mon, 1 Aug 2022 16:31:14 -0500 Subject: [PATCH 50/50] add linebreaks; ignore VS code --- .Rbuildignore | 1 + R/blue_cascade.R | 3 ++- R/fetch_county_geo.R | 3 ++- R/import_from_gis.R | 9 ++++++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 7594f5c..47b825a 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,3 +13,4 @@ ^doc$ ^Meta$ ^inst/r/key_setup\.R$ +^\.vscode$ diff --git a/R/blue_cascade.R b/R/blue_cascade.R index f58b5fb..4fb2b62 100644 --- a/R/blue_cascade.R +++ b/R/blue_cascade.R @@ -2,7 +2,8 @@ #' #' @description A named list of background and text colors for cascading menus #' -#' @format A named list of 8 lists. Each item contains a named list of two items: +#' @format A named list of 8 lists. Each item contains a named list +#' of two items: #' - "background" is the background or fill color #' - "color" is the text or contrast color #' \describe{ diff --git a/R/fetch_county_geo.R b/R/fetch_county_geo.R index f5f5934..3e601dd 100644 --- a/R/fetch_county_geo.R +++ b/R/fetch_county_geo.R @@ -1,6 +1,7 @@ #' @title Fetch standardized county geography #' -#' @param core logical, whether to include all counties in the MPO. Default is `TRUE`. +#' @param core logical, whether to include all counties in the MPO. +#' Default is `TRUE`. #' @param ... Arguments passed to `[tigris::counties]` #' #' @return An [`sf`] object containing county geographies. diff --git a/R/import_from_gis.R b/R/import_from_gis.R index 5e0b123..928dfe6 100644 --- a/R/import_from_gis.R +++ b/R/import_from_gis.R @@ -7,9 +7,12 @@ #' @param pwd character, user password. Default is `getOption("councilR.pwd")`. #' #' @note See `vignette("Options")` to review package options. -#' You must be set up with the appropriate database drivers to use this function. -#' **Windows** users need ODBC with Microsoft SQL. Contact IS support for ODBC installation. -#' **Mac** users need `unixodbc` and `freetds`. See instructions in the [onboarding guide](https://furry-adventure-596f3adb.pages.github.io/database-connections.html) +#' You must be set up with the appropriate database drivers +#' to use this function. +#' **Windows** users need ODBC with Microsoft SQL. +#' Contact IS support for ODBC installation. +#' **Mac** users need `unixodbc` and `freetds`. +#' See instructions in the [onboarding guide](https://furry-adventure-596f3adb.pages.github.io/database-connections.html) #' #' This function relies on `[{rlang}]` internal functions.