Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TADA_CreateParamRef() and TADA_CreateParamUseRef() #555

Open
wants to merge 105 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 97 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
33429a3
TADA_CreateParamRef() and TADA_CreateParamUseRef()
wokenny13 Dec 13, 2024
7e5c6dd
pushed devtool document()
wokenny13 Dec 13, 2024
785e4c7
Merge branch 'develop' into Create-Module-3-Reference-Tables
wokenny13 Dec 13, 2024
359d20e
Update WORDLIST
hillarymarler Dec 16, 2024
df513ad
Update R documentation for errors
wokenny13 Dec 16, 2024
2816e3e
updates
wokenny13 Dec 16, 2024
c9d4ad2
arg input name misspell fix and removal of intermediate objects
wokenny13 Dec 16, 2024
67da081
Update CriteriaInputs.R
wokenny13 Dec 16, 2024
fb47bfd
Update CriteriaInputs.R
wokenny13 Dec 16, 2024
c513fb7
Changed order of creating ATTAINS_param_all variable
wokenny13 Dec 16, 2024
75be2ec
Update test-URLChecker.R
hillarymarler Dec 16, 2024
8514702
Update CriteriaInputs.R
hillarymarler Dec 16, 2024
797230f
Update CriteriaInputs.R
hillarymarler Dec 17, 2024
b328058
Updated ATTAINS.FlagParameterName
wokenny13 Dec 17, 2024
14a7f8c
Mod 3 vignette testing and updates
wokenny13 Dec 18, 2024
5359692
Update documentation and excel formula logic
wokenny13 Dec 20, 2024
ab32395
Speed up loops within both functions and additional edits
wokenny13 Dec 20, 2024
4461bfa
Additional comments and further updates
wokenny13 Dec 23, 2024
44f9246
Addressed some ref documentation
wokenny13 Dec 23, 2024
38912fd
Merge branch 'develop' into Create-Module-3-Reference-Tables
cristinamullin Dec 23, 2024
45df19d
run spelling check and update wordlist
cristinamullin Dec 23, 2024
22c0f68
Merge branch 'Create-Module-3-Reference-Tables' of https://github.com…
wokenny13 Dec 24, 2024
7b69b29
Update CST EPA 304a Ref table
wokenny13 Dec 24, 2024
e6b7357
CreateParamUseRef() and CST ref
wokenny13 Dec 24, 2024
661a63e
further updates to reflect dependencies on CST ref file changes
wokenny13 Dec 24, 2024
34ff02b
test ppt
cristinamullin Dec 27, 2024
6cc04b1
Format updates, text updates, mod 3 vignette updates
wokenny13 Dec 27, 2024
b4c3a71
Merge branch 'develop' into Create-Module-3-Reference-Tables
wokenny13 Dec 27, 2024
98c22b9
Update CriteriaInputs.R
wokenny13 Dec 27, 2024
17f59e7
update mod 3 vignette
wokenny13 Dec 27, 2024
d17bfdd
outline
cristinamullin Dec 27, 2024
20e0ddc
mod 3 vignette update
wokenny13 Dec 30, 2024
1d9f740
Update NMC Mar 2025.qmd
cristinamullin Dec 30, 2024
c84b16e
update workshop presentation
cristinamullin Dec 30, 2024
8cee958
Update NMC Mar 2025.qmd
cristinamullin Dec 30, 2024
bb694df
global variables message fix
wokenny13 Dec 31, 2024
42c06f3
Updates, global variable message handling, and text fixes
wokenny13 Dec 31, 2024
0fdf963
change to pptx
cristinamullin Jan 2, 2025
8970ec5
Notes and minor fixes
wokenny13 Jan 2, 2025
7396485
Removed function CreateAUIDRef()
wokenny13 Jan 3, 2025
6947abc
mods 1 and 3 review
cristinamullin Jan 3, 2025
b0bd5b4
Merge branch 'Create-Module-3-Reference-Tables' of https://github.com…
cristinamullin Jan 3, 2025
bd3a842
update example data
cristinamullin Jan 7, 2025
7db1fb1
update docs
cristinamullin Jan 7, 2025
7988b1b
update WQX ref and add test
cristinamullin Jan 8, 2025
2d0908a
AURef update, and CST.csv update
wokenny13 Jan 8, 2025
c2f5236
fix pH unit harmonization
cristinamullin Jan 8, 2025
3863ef5
style, update example data
cristinamullin Jan 8, 2025
dad6805
Mod 3 update and TADA_CreateAURef() function included
wokenny13 Jan 8, 2025
cf8c378
Merge branch 'Create-Module-3-Reference-Tables' of https://github.com…
wokenny13 Jan 8, 2025
d221275
Removed AU_ML crosswalk draft from this branch
wokenny13 Jan 8, 2025
cb3606a
remove export of in development functions in namespace
wokenny13 Jan 10, 2025
5bdc2a7
update TADAModule1_AdvancedTraining.Rmd
cristinamullin Jan 10, 2025
8a68960
use PH_NA_NA_STD UNITS
cristinamullin Jan 10, 2025
4c9702f
Update TADAModule3.Rmd
wokenny13 Jan 10, 2025
c9e85a0
Merge branch 'Create-Module-3-Reference-Tables' of https://github.com…
wokenny13 Jan 10, 2025
9acdd69
flag suspect pH units
cristinamullin Jan 10, 2025
8df3e2b
Merge branch 'Create-Module-3-Reference-Tables' of https://github.com…
wokenny13 Jan 10, 2025
80a4c70
update TADA_GetATTAINS docs
cristinamullin Jan 10, 2025
fc8dd69
Merge branch 'Create-Module-3-Reference-Tables' of https://github.com…
wokenny13 Jan 10, 2025
660a6dd
update refs, mod 3 updates
cristinamullin Jan 10, 2025
1a3ac3b
Mod 3 vignette updates
wokenny13 Jan 10, 2025
56542f9
Merge branch 'Create-Module-3-Reference-Tables' of https://github.com…
wokenny13 Jan 10, 2025
99831f7
Created a Dataframe with button function
wokenny13 Jan 10, 2025
b0820fd
Added missing @param
wokenny13 Jan 10, 2025
8414798
Update TADA_CreateParamUseRef.Rd
wokenny13 Jan 10, 2025
9a5d59a
Update TADAModule3.Rmd
wokenny13 Jan 14, 2025
3fa96ca
Update TADAModule3.Rmd
wokenny13 Jan 15, 2025
2339205
Update test-Utilities.R
wokenny13 Jan 21, 2025
38aabd8
Update CriteriaInputs.R
wokenny13 Jan 21, 2025
73b030c
Update TADAModule3.Rmd
hillarymarler Jan 21, 2025
d4b81e7
Update TADAModule3.Rmd
hillarymarler Jan 21, 2025
579a4d4
Update NMC Mar 2025.qmd
cristinamullin Jan 22, 2025
774b557
add section on contributing to tada
cristinamullin Jan 22, 2025
61cb2df
TADA updates
cristinamullin Jan 22, 2025
776221e
Update DESCRIPTION
cristinamullin Jan 23, 2025
fe1f52a
add TADA mod 2
cristinamullin Jan 23, 2025
908e7fe
adjust times
cristinamullin Jan 23, 2025
91363a1
Changed Organization_name to Organization_identifier
wokenny13 Jan 24, 2025
29820d0
Merge branch 'Create-Module-3-Reference-Tables' into NMC-Mar-2025
cristinamullin Jan 27, 2025
1983664
Merge branch 'develop' into Create-Module-3-Reference-Tables
wokenny13 Jan 28, 2025
c3df14a
Update TADA_AutoFilter.Rd
wokenny13 Jan 28, 2025
9961adb
Utilities.R from develop
wokenny13 Jan 29, 2025
731e659
Update examples
wokenny13 Jan 29, 2025
b4a8f60
Ran document() .Rd output
wokenny13 Jan 29, 2025
6ad665b
styler and document updates
wokenny13 Jan 30, 2025
6079e2d
Merge branch 'NMC-Mar-2025' into Create-Module-3-Reference-Tables
cristinamullin Jan 31, 2025
90050f3
Update NMC Mar 2025.qmd
cristinamullin Jan 31, 2025
833b405
update refs and example data
cristinamullin Jan 31, 2025
014a004
update mod 3 vignette
cristinamullin Feb 4, 2025
a4fe915
simplify
cristinamullin Feb 4, 2025
a638d69
add part A
cristinamullin Feb 4, 2025
e1990c9
Update .gitignore
cristinamullin Feb 5, 2025
7754a8e
add quarto
cristinamullin Feb 5, 2025
c26359c
Update DESCRIPTION
cristinamullin Feb 5, 2025
6835179
Update NMC Mar 2025.qmd
cristinamullin Feb 5, 2025
08fff92
render
cristinamullin Feb 5, 2025
15eb5c3
organize functions, update vignettes
cristinamullin Feb 5, 2025
3eb7860
reorganize
cristinamullin Feb 5, 2025
343094f
maintenance
cristinamullin Feb 5, 2025
5f634c4
fix TADA_AutoClean doc example
cristinamullin Feb 6, 2025
dddbd87
Cleaned and tidied up code
wokenny13 Feb 6, 2025
e0debd7
example rdoc error fix
wokenny13 Feb 6, 2025
3911cf9
Update NMC Mar 2025.qmd
cristinamullin Feb 7, 2025
207dd3b
change qmd to rmd
cristinamullin Feb 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ readme.html
.gitignore
^articles
^vignettes/articles$
^vignettes/articles/\.quarto$
^vignettes/articles/*_files$
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ testing_log.txt

# test data from AK
AK_EPATADA_troubleshooting

# built and rendered vignettes aren't tracked
inst/doc
vignettes/*.html
vignettes/*.R
**/.quarto/
14 changes: 9 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ Imports:
nhdplusTools,
arcgislayers,
httr,
jsonlite,
rATTAINS
jsonlite,
openxlsx,
rATTAINS,
DT
Depends:
R (>= 3.5.0)
Suggests:
lwgeom,
DT,
RColorBrewer,
rmarkdown,
readr,
Expand All @@ -91,11 +92,14 @@ Suggests:
pkgdown,
spelling,
htmltools,
yaml
yaml,
quarto,
remotes
VignetteBuilder: knitr, rmarkdown
Language: en-US
Config/testthat/edition: 3
Config/testthat/load-all: list(export_all = FALSE, helpers = FALSE)
URL: https://usepa.github.io/EPATADA/, https://github.com/USEPA/EPATADA, usepa.github.io/EPATADA
URL: https://usepa.github.io/EPATADA/, https://github.com/USEPA/EPATADA
LazyData: true
LazyDataCompression: xz
Config/Needs/website: quarto, rmarkdown
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export(TADA_AutoClean)
export(TADA_AutoFilter)
export(TADA_BigDataRetrieval)
export(TADA_Boxplot)
export(TADA_CSVExport)
export(TADA_CalculateTotalNP)
export(TADA_CharStringRemoveNA)
export(TADA_CheckRequiredFields)
Expand All @@ -16,6 +17,8 @@ export(TADA_ConvertResultUnits)
export(TADA_ConvertSpecialChars)
export(TADA_CreateComparableID)
export(TADA_CreatePairRef)
export(TADA_CreateParamRef)
export(TADA_CreateParamUseRef)
export(TADA_CreateUnitRef)
export(TADA_DataRetrieval)
export(TADA_DepthProfilePlot)
Expand Down Expand Up @@ -43,10 +46,12 @@ export(TADA_FormatDelimitedString)
export(TADA_GetATTAINS)
export(TADA_GetATTAINSAUSiteCrosswalk)
export(TADA_GetATTAINSOrgIDsRef)
export(TADA_GetATTAINSParamUseOrgRef)
export(TADA_GetActivityTypeRef)
export(TADA_GetCharacteristicRef)
export(TADA_GetDetCondRef)
export(TADA_GetDetLimitRef)
export(TADA_GetEPA304aRef)
export(TADA_GetMeasureQualifierCodeRef)
export(TADA_GetMeasureUnitRef)
export(TADA_GetMonLocByOrgId)
Expand Down
16 changes: 8 additions & 8 deletions R/ATTAINSRefTables.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@ TADA_GetATTAINSOrgIDsRef <- function() {
if (!is.null(ATTAINSOrgIDsRef_Cached)) {
return(ATTAINSOrgIDsRef_Cached)
}

# Try to download up-to-date raw data

raw.data <- tryCatch(
{
# get data from ATTAINS
rATTAINS::domain_values(domain_name = "OrgName")
rATTAINS::domain_values(domain_name = "OrgName")
},
error = function(err) {
NULL
}
)

# If the download failed fall back to internal data (and report it)
if (is.null(raw.data)) {
message("Downloading latest ATTAINS Organization Reference Table failed!")
message("Falling back to (possibly outdated) internal file.")
return(utils::read.csv(system.file("extdata", "ATTAINSOrgIDsRef.csv", package = "EPATADA")))
}

ATTAINSOrgIDsRef <- raw.data %>%
dplyr::distinct()

# Save updated table in cache
ATTAINSOrgIDsRef_Cached <- ATTAINSOrgIDsRef

ATTAINSOrgIDsRef
}

Expand All @@ -53,4 +53,4 @@ TADA_UpdateATTAINSOrgIDsRef <- function() {


# Used to store cached Measure Unit Reference Table
ATTAINSOrgIDsRef_Cached <- NULL
ATTAINSOrgIDsRef_Cached <- NULL
984 changes: 984 additions & 0 deletions R/CriteriaInputs.R

Large diffs are not rendered by default.

148 changes: 82 additions & 66 deletions R/CrosswalksFromATTAINS.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
#' Crosswalk from ATTAINS
#'
#' Tribes and States who participate in electronic reporting of water quality
#' conditions through EPA ATTAINS may also submit a crosswalk of WQP
#' MonitoringLocationIdentifiers associated with their Assessment Units to
#' ATTAINS. If the organization has recorded MonitoringLocationIdentifiers
#' conditions through EPA ATTAINS may also submit a crosswalk of WQP
#' MonitoringLocationIdentifiers associated with their Assessment Units to
#' ATTAINS. If the organization has recorded MonitoringLocationIdentifiers
#' associated with their Assessment Units in ATTAINS, this function can be used
#' to create a crosswalk of known MonitoringLocationIdentifiers and Assessment
#' Units. All tribal nations record this crosswalk in ATTAINS but only a few
#' states. If a state has not supplied Monitoring Location information to
#' Units. All tribal nations record this crosswalk in ATTAINS but only a few
#' states. If a state has not supplied Monitoring Location information to
#' ATTAINS, the function will not return a data frame.
#'
#' @param org_id The ATTAINS organization identifier must be supplied by the
#' user. A list of organization identifiers can be found by downloading the
#' ATTAINS Domains Excel file:
#' https://www.epa.gov/system/files/other-files/2023-09/DOMAINS.xlsx.
#' @param org_id The ATTAINS organization identifier must be supplied by the
#' user. A list of organization identifiers can be found by downloading the
#' ATTAINS Domains Excel file:
#' https://www.epa.gov/system/files/other-files/2023-09/DOMAINS.xlsx.
#' Organization identifiers are listed in the "OrgName" tab. The "code" column
#' contains the organization identifiers that should be used for this param.
#'
Expand All @@ -32,7 +32,8 @@
#'
#' # Pueblo of Tesuque example
#' PUEBLOOFTESUQUE_crosswalk <- TADA_GetATTAINSAUSiteCrosswalk(
#' org_id = "PUEBLOOFTESUQUE")
#' org_id = "PUEBLOOFTESUQUE"
#' )
#'
#' # Arizona example, returns blank dataframe as of 1/21/25
#' AZ_crosswalk <- TADA_GetATTAINSAUSiteCrosswalk(org_id = "21ARIZ")
Expand Down Expand Up @@ -68,12 +69,13 @@ TADA_GetATTAINSAUSiteCrosswalk <- function(org_id = NULL) {
MonitoringDataLinkText = monitoring_data_link_text
) %>%
# paste org_id in front of MLs from the specified org if they are missing
#from ATTAINS
# from ATTAINS
dplyr::mutate(MonitoringLocationIdentifier = ifelse((
OrganizationIdentifier == org_id &
stringr::str_detect(MonitoringLocationIdentifier,
org_id,
negate = TRUE)),
stringr::str_detect(MonitoringLocationIdentifier,
org_id,
negate = TRUE
)),
paste0(org_id, "-", MonitoringLocationIdentifier),
MonitoringLocationIdentifier
))
Expand Down Expand Up @@ -108,7 +110,7 @@ TADA_GetATTAINSAUSiteCrosswalk <- function(org_id = NULL) {
#' This function creates the batch upload files needed to add or update
#' Monitoring Location Identifiers in ATTAINS Assessment Unit profiles. Users
#' can specify whether all records should be overwritten (replaced) or if new
#' Monitoring Location Identifiers should be appended (added) to existing
#' Monitoring Location Identifiers should be appended (added) to existing
#' records.
#'
#' @param org_id Character argument. The ATTAINS organization identifier must
Expand All @@ -118,39 +120,39 @@ TADA_GetATTAINSAUSiteCrosswalk <- function(org_id = NULL) {
#' Organization identifiers are listed in the "OrgName" tab. The "code" column
#' contains the organization identifiers that should be used for this param.
#'
#' @param wqp_data_links Character argument. When wqp_data_links is equal to
#' "add" or "replace", the function will build the URL for the Water Quality
#' Portal Data Site page for each Monitoring Location Identifier in the data
#' frame. It will examine the response code of each URL and only retain those
#' with a 200 response, which indicates the URL is valid. When
#' wqp_data_links = "add", the URL will be added to any existing text in the
#' MS_DATA_LINK_TEXT column. When wqp_data_links = "replace", the URL will
#' replace any existing text in the MS_DATA_LINK_TEXT column. When
#' wqp_data_links = "none", no URLs will be created or added to the returned
#' @param wqp_data_links Character argument. When wqp_data_links is equal to
#' "add" or "replace", the function will build the URL for the Water Quality
#' Portal Data Site page for each Monitoring Location Identifier in the data
#' frame. It will examine the response code of each URL and only retain those
#' with a 200 response, which indicates the URL is valid. When
#' wqp_data_links = "add", the URL will be added to any existing text in the
#' MS_DATA_LINK_TEXT column. When wqp_data_links = "replace", the URL will
#' replace any existing text in the MS_DATA_LINK_TEXT column. When
#' wqp_data_links = "none", no URLs will be created or added to the returned
#' data frame. Default is wqp_data_links = "add".
#'
#' @param attains_replace Character argument. When attains_replace = FALSE, all
#' Monitoring Location Identifiers in the user supplied crosswalk will be
#' appended to the existing ATTAINS crosswalk. When attains_replace = TRUE,
#' Monitoring Location Identifiers will only be retained if they are in the
#' Monitoring Location Identifiers in the user supplied crosswalk will be
#' appended to the existing ATTAINS crosswalk. When attains_replace = TRUE,
#' Monitoring Location Identifiers will only be retained if they are in the
#' user supplied crosswalk. Default equals FALSE.
#'
#' @param crosswalk A user-supplied dataframe with the columns
#' @param crosswalk A user-supplied dataframe with the columns
#' ASSESSMENT_UNIT_ID, MS_LOCATION_ID, MS_ORG_ID, and MONITORING_DATA_LINK_TEXT
#' is required. The ASSESSMENT_UNIT_ID and MS_LOCATION_ID must be filled out
#' in order to use this function. The additional columns,
#' MONITORING_DATA_LINK_TEXT, containing a single URL or "; " separated URLs
#' linking to information about the Monitoring Location, and MS_ORG_ID,
#' containing the WQP organization identifier for the Monitoring Location can
#' be left blank and the function will still run. Data link URLS to WQP site
#' pages cannot be automatically generated by this function unless the
#' MS_ORG_ID column is populated with the WQP OrganizationIdentifier. When
#' is required. The ASSESSMENT_UNIT_ID and MS_LOCATION_ID must be filled out
#' in order to use this function. The additional columns,
#' MONITORING_DATA_LINK_TEXT, containing a single URL or "; " separated URLs
#' linking to information about the Monitoring Location, and MS_ORG_ID,
#' containing the WQP organization identifier for the Monitoring Location can
#' be left blank and the function will still run. Data link URLS to WQP site
#' pages cannot be automatically generated by this function unless the
#' MS_ORG_ID column is populated with the WQP OrganizationIdentifier. When
#' crosswalk = NULL, the crosswalk will be downloaded from ATTAINS. This allows
#' users to add URLs for the Water Quality Portal Data Site pages to the ATTAINS
#' Assessment Unit profile where possible without updating other information
#' in ATTAINS.
#'
#' @return The csv batch upload files for ATTAINS to add or update
#' @return The csv batch upload files for ATTAINS to add or update
#' Monitoring Locations.
#'
#' @export
Expand All @@ -165,7 +167,7 @@ TADA_GetATTAINSAUSiteCrosswalk <- function(org_id = NULL) {
#' wqp_data_links = "replace"
#' )
#'
#' # Alaska example using a user supplied crosswalk to update entries in
#' # Alaska example using a user supplied crosswalk to update entries in
#' # ATTAINS by appending user supplied information to ATTAINS crosswalk
#'
#' # example monitoring location identifiers
Expand All @@ -174,40 +176,46 @@ TADA_GetATTAINSAUSiteCrosswalk <- function(org_id = NULL) {
#' "AK_M_1021109_013", "AK_M_1021109_013",
#' "AK_M_1021109_013"
#' )
#'
#'
#' # example organization identifiers
#' MS_ORG_ID <- c("AKDECWQ", "AKDECWQ", "AKDECWQ", "AKDECWQ", "AKDECWQ")
#'
#'
#' # example assessment units
#' MS_LOCATION_ID <- c("ExampleSite1", "ExampleSite2", "ExampleSite3",
#' "ExampleSite4", "ExampleSite5")
#' MS_LOCATION_ID <- c(
#' "ExampleSite1", "ExampleSite2", "ExampleSite3",
#' "ExampleSite4", "ExampleSite5"
#' )
#' # example urls
#' MONITORING_DATA_LINK_TEXT <- c(
#' "https://www.waterqualitydata.us/provider/STORET/AKDECWQ/",
#' "https://www.waterqualitydata.us/provider/STORET/AKDECWQ/",
#' "https://www.waterqualitydata.us/provider/STORET/AKDECWQ/",
#' "https://www.waterqualitydata.us/provider/STORET/AKDECWQ/",
#' "https://www.waterqualitydata.us/provider/STORET/AKDECWQ/")
#' "https://www.waterqualitydata.us/provider/STORET/AKDECWQ/",
#' "https://www.waterqualitydata.us/provider/STORET/AKDECWQ/",
#' "https://www.waterqualitydata.us/provider/STORET/AKDECWQ/",
#' "https://www.waterqualitydata.us/provider/STORET/AKDECWQ/",
#' "https://www.waterqualitydata.us/provider/STORET/AKDECWQ/"
#' )
#'
#' # create example crosswalk data frame
#' ex.user.cw <- data.frame(MS_LOCATION_ID, MS_ORG_ID, ASSESSMENT_UNIT_ID,
#' MONITORING_DATA_LINK_TEXT)
#' ex.user.cw <- data.frame(
#' MS_LOCATION_ID, MS_ORG_ID, ASSESSMENT_UNIT_ID,
#' MONITORING_DATA_LINK_TEXT
#' )
#'
#' AK_appenduserdata <- TADA_UpdateMonitoringLocationsInATTAINS(
#' org_id = "AKDECWQ",
#' crosswalk = ex.user.cw,
#' attains_replace = FALSE,
#' wqp_data_links = "none")
#'
#' org_id = "AKDECWQ",
#' crosswalk = ex.user.cw,
#' attains_replace = FALSE,
#' wqp_data_links = "none"
#' )
#' }
#'
TADA_UpdateMonitoringLocationsInATTAINS <- function(org_id = NULL,
crosswalk = NULL,
attains_replace = FALSE,
wqp_data_links = "add") {
# get list of organization identifiers from ATTAINS
org.ref <- utils::read.csv(system.file("extdata", "ATTAINSOrgIDsRef.csv",
package = "EPATADA"))
org.ref <- utils::read.csv(system.file("extdata", "ATTAINSOrgIDsRef.csv",
package = "EPATADA"
))

# stop function if organization identifiers is not found in ATTAINS
if (!org_id %in% org.ref$code) {
Expand Down Expand Up @@ -373,8 +381,10 @@ TADA_UpdateMonitoringLocationsInATTAINS <- function(org_id = NULL,
dplyr::mutate(
MONITORING_DATA_LINK_TEXT = ifelse(
grepl("200", response.code),
paste0(MONITORING_DATA_LINK_TEXT, "; ",
MONITORING_DATA_LINK_TEXT.New),
paste0(
MONITORING_DATA_LINK_TEXT, "; ",
MONITORING_DATA_LINK_TEXT.New
),
MONITORING_DATA_LINK_TEXT
),
MONITORING_DATA_LINK_TEXT = stringr::str_remove_all(
Expand All @@ -384,14 +394,20 @@ TADA_UpdateMonitoringLocationsInATTAINS <- function(org_id = NULL,
) %>%
tidyr::separate_rows(MONITORING_DATA_LINK_TEXT, sep = ", ") %>%
dplyr::group_by(ASSESSMENT_UNIT_ID, MS_ORG_ID, MS_LOCATION_ID) %>%
suppressMessages(dplyr::summarise(MONITORING_DATA_LINK_TEXT =
paste(
unique(
MONITORING_DATA_LINK_TEXT),
collapse = ", "))) %>%
dplyr::select(ASSESSMENT_UNIT_ID,
MS_ORG_ID, MS_LOCATION_ID,
MONITORING_DATA_LINK_TEXT) %>%
suppressMessages(dplyr::summarise(
MONITORING_DATA_LINK_TEXT =
paste(
unique(
MONITORING_DATA_LINK_TEXT
),
collapse = ", "
)
)) %>%
dplyr::select(
ASSESSMENT_UNIT_ID,
MS_ORG_ID, MS_LOCATION_ID,
MONITORING_DATA_LINK_TEXT
) %>%
dplyr::distinct()
}
return(update.crosswalk)
Expand Down
3 changes: 1 addition & 2 deletions R/DataDiscoveryRetrieval.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#' characteristicName and Characteristic Group also work as an AND, therefore the
#' characteristicName must fall within the Characteristic Group when both are entered.
#'
#'
#' Users can reference the \href{https://www.epa.gov/waterdata/storage-and-retrieval-and-water-quality-exchange-domain-services-and-downloads}{WQX domain tables}
#' to find allowable values for queries, e.g., reference the WQX domain table to find countycode and statecode: https://cdx.epa.gov/wqx/download/DomainValues/County_CSV.zip
#' Alternatively, you can use the WQP services to find areas where data is available in the US: https://www.waterqualitydata.us/Codes/countycode
Expand All @@ -27,7 +26,7 @@
#' is important for categorizing result value and detection limit data, as well as
#' harmonizing key columns used in TADA. See ?TADA_AutoClean for more information.
#'
#' Note: TADA_DataRetrieval (by leveraging dataRetrieval), automatically converts
#' Note: TADA_DataRetrieval (by leveraging dataRetrieval), automatically converts
#' the date times to UTC. It also automatically converts the data to dates,
#' datetimes, numerics based on a standard algorithm. See: ?dataRetrieval::readWQPdata
#'
Expand Down
2 changes: 1 addition & 1 deletion R/DepthProfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ TADA_IDDepthProfiles <- function(.data, nresults = TRUE, nvalue = 2, aggregates
#' data(Data_6Tribes_5y_Harmonized)
#' # Create a depth profile figure with three parameters for a single monitoring location and date
#' TADA_DepthProfilePlot(Data_6Tribes_5y_Harmonized,
#' groups = c("TEMPERATURE_NA_NA_DEG C", "PH_NA_NA_NA", "DEPTH, SECCHI DISK DEPTH_NA_NA_M"),
#' groups = c("TEMPERATURE_NA_NA_DEG C", "PH_NA_NA_STD UNITS", "DEPTH, SECCHI DISK DEPTH_NA_NA_M"),
#' location = "REDLAKE_WQX-ANKE",
#' activity_date = "2018-10-04"
#' )
Expand Down
Loading
Loading