Generate a random WQP dataset
Source:R/GeospatialFunctions.R
, R/Utilities.R
TADA_RandomTestingData.Rd
Retrieves data for a period of time in the past 20 years using TADA_DataRetrieval. This function can be used for testing functions on random datasets. Only random data sets with 10 or more results will be returned. If a random dataset has fewer than 10 results, the function will automatically create another random WQP query until a df with greater than 10 results is returned.
This function retrieves water quality data for a randomly selected period within the past 20 years using TADA_DataRetrieval
.
It can be used to test functions on random datasets. The function ensures that the returned dataset contains at least 10 results.
If the initial random dataset contains fewer than 10 results, the function automatically queries another random dataset until the criteria are met.
Usage
TADA_RandomTestingData(
number_of_days = 1,
choose_random_state = FALSE,
autoclean = TRUE
)
TADA_RandomTestingData(
number_of_days = 1,
choose_random_state = FALSE,
autoclean = TRUE
)
Arguments
- number_of_days
Numeric. Specifies the number of days for which data will be queried. The default is 1, which queries data for a random two-day period (e.g., startDate = "2015-04-21", endDate = "2015-04-22"). Users can increase this number to retrieve data for more days.
- choose_random_state
Boolean (TRUE or FALSE). Default is FALSE. If FALSE, the function queries all available WQP data for the specified number_of_days (national query). If TRUE, the function selects a random state and retrieves data only for that state.
- autoclean
Boolean (TRUE or FALSE). Default is TRUE. If TRUE, the function applies
TADA_AutoClean
as part of theTADA_DataRetrieval
. If FALSE, the function does not applyTADA_AutoClean
.
Examples
if (FALSE) { # \dontrun{
df <- TADA_RandomTestingData(number_of_days = 1, choose_random_state = FALSE)
df <- TADA_RandomTestingData(number_of_days = 10, choose_random_state = TRUE)
df <- TADA_RandomTestingData(number_of_days = 5, choose_random_state = TRUE, autoclean = FALSE)
} # }
if (FALSE) { # \dontrun{
# Example 1: Retrieve a random dataset for a single day
# across the entire nation
random_data_national <- TADA_RandomTestingData(
number_of_days = 1,
choose_random_state = FALSE
)
print(random_data_national)
# Example 2: Retrieve a random dataset for a 10-day period within
# a randomly selected state
random_data_state <- TADA_RandomTestingData(
number_of_days = 10,
choose_random_state = TRUE
)
print(random_data_state)
# Example 3: Retrieve a random dataset for a 5-day period
# within a randomly selected state without auto-cleaning
random_data_state_no_clean <- TADA_RandomTestingData(
number_of_days = 5,
choose_random_state = TRUE, autoclean = FALSE
)
print(random_data_state_no_clean)
# Example 4: Retrieve a random dataset for a 30-day period
# across the entire nation with auto-cleaning
random_data_large_period <- TADA_RandomTestingData(
number_of_days = 30,
choose_random_state = FALSE, autoclean = TRUE
)
print(random_data_large_period)
# Example 5: Retrieve a random dataset for a 15-day period
# across the entire nation without auto-cleaning
random_data_no_clean <- TADA_RandomTestingData(
number_of_days = 15,
choose_random_state = FALSE, autoclean = FALSE
)
print(random_data_no_clean)
} # }