TADA_Scatterplot: Create Scatterplot(s)

View source: R/Figures.R

TADA_ScatterplotR Documentation

Create Scatterplot(s)

Description

Create Scatterplot(s)

Usage

TADA_Scatterplot(.data, id_cols = c("TADA.ComparableDataIdentifier"))

Arguments

.data

TADA dataframe containing the data downloaded from the WQP, where each row represents a unique data record. Dataframe must include the columns 'TADA.ComparableDataIdentifier', 'TADA.ResultMeasureValue', and 'TADA.ResultMeasure.MeasureUnitCode' to run this function. The 'TADA.ComparableDataIdentifier' column is added to the dataframe automatically when WQP data is retrieved using TADADataRetrieval. This TADA.ComparableDataIdentifier can be updated to harmonize synonyms by running the function TADA_HarmonizeSynonyms(). You can also include additional grouping columns in the id_cols input if desired. If more than one TADA.ComparableDataIdentifier exists in the dataset, the function creates a list of plots, where each list element name is a unique TADA.ComparableDataIdentifier.

id_cols

The column(s) in the dataset used to identify the unique groups to be plotted. Defaults to 'TADA.ComparableDataIdentifier'.

Value

A list of plotly scatterplot figures showing the distribution of sample values for each comparable data group (TADA.ComparableDataIdentifier).

Examples

# Load example dataset:
data(Data_6Tribes_5y_Harmonized)

# Create a scatterplot for each comparable data group (TADA.ComparableDataIdentifier)
# in the input dataframe:
TADA_Scatterplot(Data_6Tribes_5y_Harmonized, id_cols = "TADA.ComparableDataIdentifier")

# Create a single scatterplot using defaults. The input dataframe in this
# example is filtered so it includes only one TADA.ComparableDataIdentifier
df <- dplyr::filter(
  Data_6Tribes_5y_Harmonized,
  TADA.ComparableDataIdentifier ==
    "TOTAL PHOSPHORUS, MIXED FORMS_UNFILTERED_AS P_UG/L"
)
TADA_Scatterplot(df, id_cols = "TADA.ComparableDataIdentifier")
# Creates a scatterplot for each monitoring location
TADA_Scatterplot(df, id_cols = c("TADA.ComparableDataIdentifier", "MonitoringLocationName"))

# Create multiple scatterplots with additional grouping columns and view the first
# plot in list. In this example, we will group by both TADA.ComparableDataIdentifier
# and MonitoringLocationTypeName (e.g. stream, reservoir, canal, etc.)
# Load example dataset:
data(Data_Nutrients_UT)
Scatterplot_output <- TADA_Scatterplot(Data_Nutrients_UT,
  id_cols = c("TADA.ComparableDataIdentifier", "MonitoringLocationTypeName")
)
# This example generates 47 scatterplots
Scatterplot_output[[10]]
Scatterplot_output[[25]]
Scatterplot_output[[35]]


USEPA/TADA documentation built on April 12, 2025, 1:47 p.m.