Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export(TADA_ColorPalette)
export(TADA_ConvertDepthUnits)
export(TADA_ConvertResultUnits)
export(TADA_ConvertSpecialChars)
export(TADA_CreateCSV)
export(TADA_CreateComparableID)
export(TADA_CreatePairRef)
export(TADA_CreateParamRef)
Expand Down
144 changes: 78 additions & 66 deletions R/DataDiscoveryRetrieval.R
Original file line number Diff line number Diff line change
Expand Up @@ -1070,37 +1070,43 @@ TADA_TribalOptions <- function(tribal_area_type, return_sf = FALSE) {
#' @examples
#' \dontrun{
#' # construct the WQP web service URL for each profile
#' baseurl = "https://www.waterqualitydata.us/data/"
#' profile_station = "Station"
#' profile_result = "Result"
#' profile_result_2 = "&dataProfile=biological"
#' profile_project = "Project"
#' filters = "/search?statecode=US%3A09&sampleMedia=water&sampleMedia=Water"
#' dates = "&startDateLo=01-01-2021&startDateHi=02-01-2021"
#' type = "&mimeType=csv&zip=yes"
#' providers = "&providers=NWIS&providers=STEWARDS&providers=STORET"
#'
#' physchemresults1 <- TADA_ReadWQPWebServices(paste0(baseurl,
#' profile_station,
#' filters,
#' dates,
#' type,
#' providers))
#'
#' sites1 <- TADA_ReadWQPWebServices(paste0(baseurl,
#' profile_result,
#' filters,
#' dates,
#' type,
#' profile_result_2,
#' providers))
#'
#' projects1 <- TADA_ReadWQPWebServices(paste0(baseurl,
#' profile_project,
#' filters,
#' dates,
#' type,
#' providers))
#' baseurl <- "https://www.waterqualitydata.us/data/"
#' profile_station <- "Station"
#' profile_result <- "Result"
#' profile_result_2 <- "&dataProfile=biological"
#' profile_project <- "Project"
#' filters <- "/search?statecode=US%3A09&sampleMedia=water&sampleMedia=Water"
#' dates <- "&startDateLo=01-01-2021&startDateHi=02-01-2021"
#' type <- "&mimeType=csv&zip=yes"
#' providers <- "&providers=NWIS&providers=STEWARDS&providers=STORET"
#'
#' physchemresults1 <- TADA_ReadWQPWebServices(paste0(
#' baseurl,
#' profile_station,
#' filters,
#' dates,
#' type,
#' providers
#' ))
#'
#' sites1 <- TADA_ReadWQPWebServices(paste0(
#' baseurl,
#' profile_result,
#' filters,
#' dates,
#' type,
#' profile_result_2,
#' providers
#' ))
#'
#' projects1 <- TADA_ReadWQPWebServices(paste0(
#' baseurl,
#' profile_project,
#' filters,
#' dates,
#' type,
#' providers
#' ))
#' }
#'
TADA_ReadWQPWebServices <- function(webservice) {
Expand Down Expand Up @@ -1269,9 +1275,9 @@ TADA_BigDataHelper <- function(record_summary, WQPquery, maxrecs = 250000, maxsi
#' After retrieving multiple result and metadata profiles from the WQP, this
#' function joins those profiles together into one dataframe.
#' The FullPhysChem data input is required to run this function.
#'
#' The WQP user interface assists users with constructing a web service query
#' URL - for example:
#'
#' The WQP user interface assists users with constructing a web service query
#' URL - for example:
#' https://www.waterqualitydata.us/#statecode=US%3A09&characteristicType=Nutrient&startDateLo=04-01-2023&startDateHi=11-01-2023&mimeType=csv&providers=NWIS&providers=STEWARDS&providers=STORET
#'
#' @param FullPhysChem Full physical chemical data profile
Expand All @@ -1285,38 +1291,44 @@ TADA_BigDataHelper <- function(record_summary, WQPquery, maxrecs = 250000, maxsi
#' @examples
#' \dontrun{
#' # construct the WQP web service URL for each profile
#' baseurl = "https://www.waterqualitydata.us/data/"
#' profile_station = "Station"
#' profile_result = "Result"
#' profile_result_2 = "&dataProfile=resultPhysChem"
#' profile_project = "Project"
#' filters = "/search?statecode=US%3A09&characteristicType=Nutrient"
#' dates = "&startDateLo=04-01-2023&startDateHi=11-01-2023"
#' type = "&mimeType=csv&zip=yes"
#' providers = "&providers=NWIS&providers=STEWARDS&providers=STORET"
#'
#' stationProfile <- TADA_ReadWQPWebServices(paste0(baseurl,
#' profile_station,
#' filters,
#' dates,
#' type,
#' providers))
#'
#' physchemProfile <- TADA_ReadWQPWebServices(paste0(baseurl,
#' profile_result,
#' filters,
#' dates,
#' type,
#' profile_result_2,
#' providers))
#'
#' projectProfile <- TADA_ReadWQPWebServices(paste0(baseurl,
#' profile_project,
#' filters,
#' dates,
#' type,
#' providers))
#'
#' baseurl <- "https://www.waterqualitydata.us/data/"
#' profile_station <- "Station"
#' profile_result <- "Result"
#' profile_result_2 <- "&dataProfile=resultPhysChem"
#' profile_project <- "Project"
#' filters <- "/search?statecode=US%3A09&characteristicType=Nutrient"
#' dates <- "&startDateLo=04-01-2023&startDateHi=11-01-2023"
#' type <- "&mimeType=csv&zip=yes"
#' providers <- "&providers=NWIS&providers=STEWARDS&providers=STORET"
#'
#' stationProfile <- TADA_ReadWQPWebServices(paste0(
#' baseurl,
#' profile_station,
#' filters,
#' dates,
#' type,
#' providers
#' ))
#'
#' physchemProfile <- TADA_ReadWQPWebServices(paste0(
#' baseurl,
#' profile_result,
#' filters,
#' dates,
#' type,
#' profile_result_2,
#' providers
#' ))
#'
#' projectProfile <- TADA_ReadWQPWebServices(paste0(
#' baseurl,
#' profile_project,
#' filters,
#' dates,
#' type,
#' providers
#' ))
#'
#' # Join all three profiles using TADA_JoinWQPProfiles
#' TADAProfile <- TADA_JoinWQPProfiles(
#' FullPhysChem = physchemProfile,
Expand Down
33 changes: 32 additions & 1 deletion R/Utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,7 @@ TADA_ViewColorPalette <- function(col_pair = FALSE) {
return(swatch)
}


#' Remove NAs in Strings for Figure Titles and Axis Labels
#'
#' Returns a vector of string(s) that removes common NA strings
Expand Down Expand Up @@ -1835,6 +1836,7 @@ TADA_CharStringRemoveNA <- function(char_string) {
return(labs)
}


#' Create downloadable table
#'
#' This function creates a data table that can be downloaded as a .csv, .xlsx or .pdf.
Expand All @@ -1852,7 +1854,7 @@ TADA_CharStringRemoveNA <- function(char_string) {
#' }
TADA_TableExport <- function(.data = NULL) {
if (is.null(.data)) {
print("No dataframe provided. Please enter a dataframe to return")
stop("Input object must be of class 'data.frame'")
}

data <- DT::datatable(.data,
Expand All @@ -1872,3 +1874,32 @@ TADA_TableExport <- function(.data = NULL) {

return(data)
}


#' Create and download .csv
#'
#' This function creates a .csv file and exports it to a user's download folder
#' with the name of the data frame as the file name.
#'
#' @param .data A data frame.
#'
#' @export
#'
#' @examples
#' \dontrun{
#' # Returns a .csv file of the example Data_Nutrients_UT TADA data frame.
#' TADA_CreateCSV(Data_Nutrients_UT)
#' }
TADA_CreateCSV <- function(.data) {
if (!is.data.frame(.data)) {
stop("Input object must be of class 'data.frame'")
}

df_name <- deparse(substitute(.data))

downloads_path <- file.path(Sys.getenv("USERPROFILE"), "Downloads", paste0(df_name, ".csv"))

write.csv(.data, file = downloads_path, row.names = FALSE)

cat("File saved to:", gsub("/", "\\\\", downloads_path), "\n")
}
21 changes: 21 additions & 0 deletions man/TADA_CreateCSV.Rd

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

62 changes: 34 additions & 28 deletions man/TADA_JoinWQPProfiles.Rd

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

62 changes: 34 additions & 28 deletions man/TADA_ReadWQPWebServices.Rd

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

Loading