Skip to contents

Create Scatterplot(s) for Each TADA.ComparableDataIdentifier with Multiple (Up to 4) Groupings by an Additional Column

Usage

TADA_GroupedScatterplot(
  .data,
  group_col = "MonitoringLocationName",
  groups = NULL
)

Arguments

.data

TADA data frame where each row represents a unique record. Data frame must include the columns 'TADA.ComparableDataIdentifier', 'TADA.ResultMeasureValue', 'TADA.ResultMeasure.MeasureUnitCode', 'ActivityStartDate', 'ActivityStartDateTime', 'ActivityStartDateTime', 'MonitoringLocationName', 'TADA.ActivityMediaName', 'ActivityMediaSubdivisionName', 'TADA.ResultDepthHeightMeasure.MeasureValue', 'TADA.ResultDepthHeightMeasure.MeasureValue', 'TADA.ResultDepthHeightMeasure.MeasureUnitCode', 'ActivityRelativeDepthName', 'TADA.ActivityDepthHeightMeasure.MeasureValue', 'TADA.ActivityDepthHeightMeasure.MeasureUnitCode', 'TADA.ActivityTopDepthHeightMeasure.MeasureValue', 'TADA.ActivityTopDepthHeightMeasure.MeasureUnitCode', 'TADA.ActivityBottomDepthHeightMeasure.MeasureValue', and TADA.ActivityBottomDepthHeightMeasure.MeasureUnitCode to run this function.

group_col

The column in the dataset used to identify the groups plotted. Defaults to MonitoringLocationName. This input is flexible, and allows for the use of other identifiers such as StateCode, CountyCode or user-created groups based on concatenation of other variables (e.g. characteristic name, site type, site name, year, organization, etc.)

groups

A vector of up to four identifiers from the id_cols column to specify the groups that will be plotted for a TADA.ComparableDataIdentifier. These groups will be specific to your dataset. For example, in the example data set Data_6Tribes_5y_Harmonized if group_col is 'MonitoringLocationName', the groups could be 'Upper Red Lake: West', 'Upper Red Lake: West-Central', and 'Upper Red Lake: East Central'.

Value

A plotly scatterplot(s) figure with one x-axis (Date/Time) and a left axis showing the units of a single TADA.ComparableDataIdentifier plotted on the same figure area with. Groups are identified by different colored circle markers and are displayed in a legend.

Examples

# Load example dataset:
data(Data_Nutrients_UT)
# UT Nutrients results grouped by county
# transform non-detect data
df2 <- TADA_SimpleCensoredMethods(Data_Nutrients_UT)
#> [1] "TADA_IDCensoredData: There are 12 results in your data frame that are missing ResultDetectionConditionText. TADA requires BOTH ResultDetectionConditionText and DetectionQuantitationLimitTypeName fields to be populated in order to categorize censored data."
# create scatterplots for selected counties
UT_Nutrients_by_CountyCode <- TADA_GroupedScatterplot(df2, group_col = "CountyCode", groups = c("057", "011", "003", "037"))
# view the 3rd and 4th plots
UT_Nutrients_by_CountyCode[[3]]
UT_Nutrients_by_CountyCode[[4]]
# Load example dataset: data(Data_6Tribes_5y_Harmonized) # Filter the example data so it includes only one TADA.ComparableDataIdentifier df <- dplyr::filter(Data_6Tribes_5y_Harmonized, TADA.ComparableDataIdentifier %in% c("TOTAL PHOSPHORUS, MIXED FORMS_UNFILTERED_AS P_UG/L")) # Creates a scatterplot of the three specified sites of interest in the same plot. TADA_GroupedScatterplot(df, group_col = "MonitoringLocationName", groups = c("Upper Red Lake: West", "Upper Red Lake: West-Central", "Upper Red Lake: East Central"))
# If no groups are selected, return the 4 groups (by MonitoringLocationName) with the greatest number of results TADA_GroupedScatterplot(df, group_col = "MonitoringLocationName") #> [1] "TADA_GroupedScatterplot: No 'groups' selected for MonitoringLocationName. There are 161 MonitoringLocationNames in the TADA data frame. The top four MonitoringLocationNames by number of results will be plotted: Upper Red Lake: Central; Upper Red Lake: East; Upper Red Lake: West and Lower Red Lake : East."