diff --git a/R/Maintenance.R b/R/Maintenance.R index 533fe50b..906afded 100644 --- a/R/Maintenance.R +++ b/R/Maintenance.R @@ -232,3 +232,67 @@ FindSynonyms <- function() { # # run to update spelling word list # spelling::get_wordlist() # spelling::update_wordlist() + +# # Find Broken Links if test-URLChecker.R fails +# # Run the code below: +# # extract urls function +# extract_urls <- function(text) { +# stringr::str_extract_all(text, "http[s]?://[^\\s\\)\\]]+") %>% unlist() +# } +# +# # clean urls function +# clean_url <- function(url) { +# stringr::str_remove_all(url, "[\\\\.,\\\")]+$|[{}].*") %>% +# stringr::str_remove_all("[<>]") +# } +# +# # create lists of files to check +# other_files <- c( +# system.file("README.md", package = "EPATADA"), +# system.file("DESCRIPTION", package = "EPATADA"), +# system.file("NAMESPACE", package = "EPATADA") +# ) +# +# vignettes <- list.files(system.file("vignettes", package = "EPATADA"), pattern = ".Rmd", full.names = TRUE) +# +# articles <- list.files(system.file("vignettes/articles", package = "EPATADA"), pattern = ".Rmd", full.names = TRUE) +# +# r_files <- list.files(system.file("R", package = "EPATADA"), pattern = ".R", full.names = TRUE) +# +# # combine file lists +# files <- append(other_files, vignettes) %>% +# append(articles) %>% +# append(r_files) +# +# # create list of urls +# urls <- purrr::map(files, ~ readLines(.x)) %>% +# unlist() %>% +# extract_urls() %>% +# clean_url() %>% +# unique() %>% +# # problematic URL I can't get a response from using multiple methods (itec) and CRAN because its response is inconsistent, likely due to redirecting to mirrors (HRM 10/28/2024) +# setdiff(c( +# "https://www.itecmembers.org/attains/" +# )) +# +# # retrieve http response headers from url list +# headers <- urls %>% +# purrr::map(~ tryCatch(curlGetHeaders(.x), error = function(e) NA)) +# +# # extract response code from first line of header response +# response_code <- sapply(headers, "[[", 1) +# +# # create data frame of urls and response codes +# df <- data.frame(urls, response_code) +# +# # filter for any response codes that are not successful or redirect responses +# df_false <- df %>% +# dplyr::filter(!grepl("200", response_code) & +# !grepl("301", response_code) & +# !grepl("302", response_code)) +# +# # Review the output of df_false. +# # More information about http response codes can be found here: +# # [Mozilla Developer HTTP response status codes] (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) +# # Replace the broken links with functional ones or remove if no acceptable substitute is available. +# # Rerun code above to verify that df_false contains zero rows. \ No newline at end of file diff --git a/R/Utilities.R b/R/Utilities.R index 5ef48462..a0a5860d 100644 --- a/R/Utilities.R +++ b/R/Utilities.R @@ -1405,7 +1405,7 @@ TADA_addPoints <- function(map, layerfilepath, layergroup, layername, bbox = NUL if (is.na(lbbox[1])) { return(map) } - shapes <- c(2) # open triangle; for other options see http://www.statmethods.net/advgraphs/parameters.html + shapes <- c(2) # open triangle; for other options see https://www.geeksforgeeks.org/r-plot-pch-symbols-different-point-shapes-available-in-r/ iconFiles <- pchIcons(shapes, width = 20, height = 20, col = c("#CC7722"), lwd = 2) map <- leaflet::addMarkers( map, diff --git a/README.md b/README.md index 8083dc9d..4c38eb9f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![](https://github.com/USEPA/EPATADA/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/USEPA/EPATADA/actions/workflows/R-CMD-check.yaml) -Tools for Automated Data Analysis, or TADA, is being developed to help States, Tribes (i.e., Tribal Nations, Pueblos, Bands, Rancherias, Communities, Colonies, Towns, Indians, Villages), federal partners, and any other [Water Quality Portal (WQP)](https://www.waterqualitydata.us/) users (e.g. researchers) efficiently compile and evaluate WQP data collected from water quality monitoring sites. TADA is both a stand-alone R package, and a building block to support development of the [TADA R Shiny application](https://github.com/USEPA/EPATADAShiny). We encourage you to read this package's [LICENSE](https://usepa.github.io/EPATADA/LICENSE.html) and [README](https://usepa.github.io/EPATADA/index.html) files (you are here). +Tools for Automated Data Analysis, or TADA, is being developed to help States, Tribes (i.e., Tribal Nations, Pueblos, Bands, Rancherias, Communities, Colonies, Towns, Indians, Villages), federal partners, and any other [Water Quality Portal (WQP)](https://www.waterqualitydata.us/) users (e.g. researchers) efficiently compile and evaluate WQP data collected from water quality monitoring sites. TADA is both a stand-alone R package, and a building block to support development of the [TADA R Shiny application](https://github.com/USEPA/TADAShiny). We encourage you to read this package's [LICENSE](https://usepa.github.io/EPATADA/LICENSE.html) and [README](https://usepa.github.io/EPATADA/index.html) files (you are here). - How to use TADA: @@ -34,7 +34,7 @@ install.packages("remotes") remotes::install_github("USEPA/EPATADA", ref = "develop", dependencies = TRUE, force = TRUE) ``` -The TADA R Shiny application can be run [on the web](https://owshiny-dev.app.cloud.gov/tada-dev/) (R and R Studio install not required), or within R Studio. Run the following code within R Studio to install or update and run the most recent version of the [TADA R Shiny](https://github.com/USEPA/EPATADAShiny) application: +The TADA R Shiny application can be run [on the web](https://rconnect-public.epa.gov/TADAShiny/) (R and R Studio install not required), or within R Studio. Run the following code within R Studio to install or update and run the most recent version of the [TADA R Shiny](https://github.com/USEPA/TADAShiny) application: ```{r} if(!"remotes"%in%installed.packages()){ @@ -73,7 +73,7 @@ Effective August 8, 2016, the [OMB Mandate: M-16-21; Federal Source Code Policy: The EPA specific implementation of OMB Mandate M-16-21 is addressed in the [System Life Cycle Management Procedure](https://www.epa.gov/irmpoli8/policy-procedures-and-guidance-system-life-cycle-management-slcm). EPA has chosen to use GitHub as its version control system as well as its inventory of open-source code projects. EPA uses GitHub to inventory its custom-developed, open-source code and generate the necessary metadata file that is then posted to code.gov for broad reuse in compliance with OMB Mandate M-16-21. -If you have any questions or want to read more, check out the [EPA Open Source Project Repo](https://github.com/USEPA/open-source-projects) and [EPA's Interim Open Source Code Guidance](https://www.epa.gov/developers/open-source-software-and-epa-code-repository-requirements). +If you have any questions or want to read more, check out the [EPA Open Source Project Repo](https://www.epa.gov/developers/open-source-software-and-code-repositories) and [EPA's Interim Open Source Software Policy](https://www.epa.gov/sites/default/files/2018-02/documents/interim_oss_policy_final.pdf). ## License diff --git a/tests/testthat/test-URLChecker.R b/tests/testthat/test-URLChecker.R new file mode 100644 index 00000000..75884f27 --- /dev/null +++ b/tests/testthat/test-URLChecker.R @@ -0,0 +1,68 @@ +test_that("URLs are not broken", { + # extract urls function + extract_urls <- function(text) { + stringr::str_extract_all(text, "http[s]?://[^\\s\\)\\]]+") %>% unlist() + } + + # clean urls function + clean_url <- function(url) { + stringr::str_remove_all(url, "[\\\\.,\\\")]+$|[{}].*") %>% + stringr::str_remove_all("[<>]") + } + + # create lists of files to check + other_files <- c( + system.file("README.md", package = "EPATADA"), + system.file("DESCRIPTION", package = "EPATADA"), + system.file("NAMESPACE", package = "EPATADA") + ) + + vignettes <- list.files(system.file("vignettes", package = "EPATADA"), pattern = ".Rmd", full.names = TRUE) + + articles <- list.files(system.file("vignettes/articles", package = "EPATADA"), pattern = ".Rmd", full.names = TRUE) + + r_files <- list.files(system.file("R", package = "EPATADA"), pattern = ".R", full.names = TRUE) + + # combine file lists + files <- append(other_files, vignettes) %>% + append(articles) %>% + append(r_files) + + # create list of urls + urls <- purrr::map(files, ~ readLines(.x)) %>% + unlist() %>% + extract_urls() %>% + clean_url() %>% + unique() %>% + # problematic URL I can't get a response from using multiple methods (itec) and CRAN because its response is inconsistent, likely due to redirecting to mirrors (HRM 10/28/2024) + setdiff(c( + "https://www.itecmembers.org/attains/" + )) + + # retrieve http response headers from url list + headers <- urls %>% + purrr::map(~ tryCatch(curlGetHeaders(.x), error = function(e) NA)) + + # extract response code from first line of header response + response_code <- sapply(headers, "[[", 1) + + # create data frame of urls and response codes + df <- data.frame(urls, response_code) + + # filter for any response codes that are not successful or redirect responses + df_false <- df %>% + dplyr::filter(!grepl("200", response_code) & + !grepl("301", response_code) & + !grepl("302", response_code)) + + # count number of failed responses + n <- nrow(df_false) + + # print url and response code for failures + print(df_false) + + # verify that there are zero urls with failing response codes + testthat::expect_equal(n, 0) +}) + + diff --git a/vignettes/CONTRIBUTING.Rmd b/vignettes/CONTRIBUTING.Rmd index 2b097238..df7bab2d 100644 --- a/vignettes/CONTRIBUTING.Rmd +++ b/vignettes/CONTRIBUTING.Rmd @@ -82,9 +82,9 @@ There are multiple ways to interact with GitHub using Git. - Option 2: Interact with GitHub using the command line or a web browser - - [Setting Up Git](https://docs.github.com/articles/set-up-git/) + - [Setting Up Git](https://docs.github.com/en/get-started/getting-started-with-git/set-up-git) - - [Git Basics](https://git-scm.com/book/ch1-3.html) + - [Git Basics](https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository) - [Comprehensive Guide: Happy Git and GitHub for the useR](https://happygitwithr.com/ "Great and comprehensive guide for Git with an R flair") @@ -107,7 +107,7 @@ might be needed for Mac or Linux OS: - Download both: - - [GitHub Desktop](https://desktop.github.com/) + - [GitHub Desktop](https://github.com/apps/desktop) - [Git](https://git-scm.com/downloads) @@ -149,7 +149,7 @@ install.packages(c("devtools", "rmarkdown")) might be good first pickings for your first contribution to this open-source project. - Pull requests can be directly - [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) + [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue) to a specific issue. If linked, the Repository Administrators can more easily review the pull request and issue at the same time once a contributor submits the pull request. The issue can then be closed diff --git a/vignettes/TADAModule1.Rmd b/vignettes/TADAModule1.Rmd index 3895f1d2..439c8ca0 100644 --- a/vignettes/TADAModule1.Rmd +++ b/vignettes/TADAModule1.Rmd @@ -165,7 +165,7 @@ Additional resources: the console: ?TADA_DataRetrieval - [Introduction to the dataRetrieval - package](https://CRAN.R-project.org/package=dataRetrieval) + package](https://cran.r-project.org/web/packages/dataRetrieval/index.html) - [General Data Import from Water Quality Portal](https://rdrr.io/cran/dataRetrieval/man/readWQPdata.html) @@ -1308,7 +1308,7 @@ interface. The shiny application queries the WQP, contains maps and data visualizations, flags suspect data results, handles censored data, and more. You can launch it using the code below. -DRAFT [Module 1](https://owshiny-dev.app.cloud.gov/tada-dev/) is also +DRAFT [Module 1](https://rconnect-public.epa.gov/TADAShiny/) is also currently hosted on the web with minimal server memory/storage allocated. diff --git a/vignettes/TADAModule1_AdvancedTraining.Rmd b/vignettes/TADAModule1_AdvancedTraining.Rmd index 8a8c9433..4e289735 100644 --- a/vignettes/TADAModule1_AdvancedTraining.Rmd +++ b/vignettes/TADAModule1_AdvancedTraining.Rmd @@ -781,6 +781,6 @@ remotes::install_github("USEPA/TADAShiny", ref = "develop", dependencies = TRUE) TADAShiny::run_app() ``` -DRAFT [Module 1](https://owshiny-dev.app.cloud.gov/tada-dev/) is also +DRAFT [Module 1](https://rconnect-public.epa.gov/TADAShiny/) is also currently hosted on the web with minimal server memory/storage allocated. diff --git a/vignettes/TADAModule1_BeginnerTraining.Rmd b/vignettes/TADAModule1_BeginnerTraining.Rmd index 76672a17..418c6cd6 100644 --- a/vignettes/TADAModule1_BeginnerTraining.Rmd +++ b/vignettes/TADAModule1_BeginnerTraining.Rmd @@ -1147,7 +1147,7 @@ interface. The shiny application queries the WQP, contains maps and data visualizations, flags suspect data results, handles censored data, and more. You can launch it using the code below. -DRAFT [Module 1](https://owshiny-dev.app.cloud.gov/tada-dev/) is also +DRAFT [Module 1](https://rconnect-public.epa.gov/TADAShiny/) is also currently hosted on the web with minimal server memory/storage allocated. diff --git a/vignettes/WQXValidationService.Rmd b/vignettes/WQXValidationService.Rmd index 2de40ae8..2034a931 100644 --- a/vignettes/WQXValidationService.Rmd +++ b/vignettes/WQXValidationService.Rmd @@ -100,7 +100,7 @@ interquartile range) and a [probability density function](https://en.wikipedia.org/wiki/Probability_density_function "Probability density function") (pdf) of a Normal N(0,σ2) Population. Attribution: Jhguch at en.wikipedia, [CC BY-SA -2.5](https://creativecommons.org/licenses/by-sa/2.5), via Wikimedia +2.5](https://creativecommons.org/licenses/by-sa/2.5/), via Wikimedia Commons.](images/IQR.png)](https://commons.wikimedia.org/wiki/File:Boxplot_vs_PDF.svg) Additional tests only available in WQX Web and Node Submissions (for