diff --git a/R/Figures.R b/R/Figures.R index e94f637a..5359d920 100644 --- a/R/Figures.R +++ b/R/Figures.R @@ -67,7 +67,8 @@ TADA_Boxplot <- function(.data, id_cols = c("TADA.ComparableDataIdentifier")) { TADA_CheckColumns(.data, id_cols) # check .data has required columns - TADA_CheckColumns(.data, c("TADA.ResultMeasureValue", "TADA.ResultMeasure.MeasureUnitCode")) + TADA_CheckColumns(.data, c("TADA.ResultMeasureValue", + "TADA.ResultMeasure.MeasureUnitCode")) start <- dim(.data)[1] @@ -232,21 +233,13 @@ TADA_Histogram <- function(.data, id_cols = c("TADA.ComparableDataIdentifier")) warning("TADA.ComparableDataIdentifier not found in id_cols argument and is highly recommended: plotting without it may produce errors in the plot.") } - req_cols <- c( - "TADA.ComparableDataIdentifier", - "TADA.CharacteristicName", - "TADA.ResultSampleFractionText", - "TADA.MethodSpecificationName", - "TADA.ResultMeasure.MeasureUnitCode", - "TADA.ResultMeasureValue", - "ActivityStartDate", - "MonitoringLocationIdentifier", - "ActivityTypeCode" - ) + # check .data has required columns + TADA_CheckColumns(.data, id_cols) # check .data has required columns - TADA_CheckColumns(.data, expected_cols = req_cols) - + TADA_CheckColumns(.data, c("TADA.ResultMeasureValue", + "TADA.ResultMeasure.MeasureUnitCode")) + start <- dim(.data)[1] .data <- subset(.data, !is.na(.data$TADA.ResultMeasureValue)) @@ -549,11 +542,13 @@ TADA_Scatterplot <- function(.data, id_cols = c("TADA.ComparableDataIdentifier") warning("TADA.ComparableDataIdentifier not found in id_cols argument and is highly recommended: plotting without it may produce errors in the plot.") } + # check .data has required columns + TADA_CheckColumns(.data, id_cols) + # check .data has required columns TADA_CheckColumns(.data, c("ActivityStartDate", "TADA.ResultMeasureValue", - "TADA.ResultMeasure.MeasureUnitCode", - "TADA.ComparableDataIdentifier")) + "TADA.ResultMeasure.MeasureUnitCode")) .data <- .data %>% dplyr::group_by(dplyr::across(dplyr::all_of(id_cols))) %>% @@ -590,11 +585,13 @@ TADA_Scatterplot <- function(.data, id_cols = c("TADA.ComparableDataIdentifier") "Activity Start Date:", plot.data$ActivityStartDate, "
", "Activity Start Date Time:", plot.data$ActivityStartDateTime, "
", "Monitoring Location Name:", plot.data$MonitoringLocationName, "
", + "Media:", plot.data$TADA.ActivityMediaName, "
", + "Media Subdivision:", plot.data$ActivityMediaSubdivisionName, "
", "Result Depth:", paste0( plot.data$TADA.ResultDepthHeightMeasure.MeasureValue, " ", plot.data$TADA.ResultDepthHeightMeasure.MeasureUnitCode ), "
", - "Activity Relative Depth Name:", plot.data$ActivityRelativeDepthName, "
", + "Activity Relative Depth:", plot.data$ActivityRelativeDepthName, "
", "Activity Depth:", paste0( plot.data$TADA.ActivityDepthHeightMeasure.MeasureValue, " ", plot.data$TADA.ActivityDepthHeightMeasure.MeasureUnitCode @@ -697,13 +694,12 @@ TADA_TwoCharacteristicScatterplot <- function(.data, id_cols = "TADA.ComparableD TADA_CheckType(.data, "data.frame", "Input object") # check .data has required columns + TADA_CheckColumns(.data, id_cols) + # check .data has required columns reqcols <- c("TADA.ResultMeasureValue", "TADA.ResultMeasure.MeasureUnitCode", - "ActivityStartDate", - "ActivityStartDateTime", - "TADA.ComparableDataIdentifier", - "MonitoringLocationName") + "ActivityStartDate") # check .data has required columns TADA_CheckColumns(.data, reqcols) @@ -784,6 +780,8 @@ TADA_TwoCharacteristicScatterplot <- function(.data, id_cols = "TADA.ComparableD "Activity Start Date:", param1$ActivityStartDate, "
", "Activity Start Date Time:", param1$ActivityStartDateTime, "
", "Monitoring Location Name:", param1$MonitoringLocationName, "
", + "Media:", param1$TADA.ActivityMediaName, "
", + "Media Subdivision:", param1$ActivityMediaSubdivisionName, "
", "Result Depth:", paste0( param1$TADA.ResultDepthHeightMeasure.MeasureValue, " ", param1$TADA.ResultDepthHeightMeasure.MeasureUnitCode @@ -811,6 +809,8 @@ TADA_TwoCharacteristicScatterplot <- function(.data, id_cols = "TADA.ComparableD "Activity Start Date:", param2$ActivityStartDate, "
", "Activity Start Date Time:", param2$ActivityStartDateTime, "
", "Monitoring Location Name:", param2$MonitoringLocationName, "
", + "Media:", param2$TADA.ActivityMediaName, "
", + "Media Subdivision:", param2$ActivityMediaSubdivisionName, "
", "Result Depth:", paste0( param2$TADA.ResultDepthHeightMeasure.MeasureValue, " ", param2$TADA.ResultDepthHeightMeasure.MeasureUnitCode diff --git a/R/Tables.R b/R/Tables.R index 9f661b7c..609cc6bb 100644 --- a/R/Tables.R +++ b/R/Tables.R @@ -75,7 +75,7 @@ TADA_SummarizeColumn <- function(.data, col = "TADA.CharacteristicName") { TADA_Stats <- function(.data, group_cols = c("TADA.ComparableDataIdentifier")) { if (any(is.na(.data$TADA.ResultMeasureValue))) { sumNAs <- length(.data$TADA.ResultMeasureValue[is.na(.data$TADA.ResultMeasureValue)]) - warning(paste0("Dataset contains ", sumNAs, " results missing both a TADA result value and a detection limit. These values will not be represented in the summary table. Suggest removing or handling.")) + print(paste0("Dataset contains ", sumNAs, " results missing both a TADA result value and a detection limit. These values will not be represented in the stats summary table. Suggest removing or handling.")) } if (!"TADA.CensoredData.Flag" %in% names(.data)) { diff --git a/R/Transformations.R b/R/Transformations.R index d6ae4579..ed4269de 100644 --- a/R/Transformations.R +++ b/R/Transformations.R @@ -408,12 +408,14 @@ TADA_CalculateTotalNP <- function(.data, sum_ref, daily_agg = c("max", "min", "m depths <- names(.data)[grepl("DepthHeightMeasure", names(.data))] depths <- depths[grepl("TADA.", depths)] grpcols <- c("ActivityStartDate", - "ActivityStartDateTime", + #"ActivityStartDateTime", #does not make sense to include for daily agg "ActivityRelativeDepthName", "MonitoringLocationIdentifier", + "MonitoringLocationName", "TADA.LongitudeMeasure", "TADA.LatitudeMeasure", "ActivityMediaSubdivisionName", + "TADA.ActivityMediaName", "TADA.ComparableDataIdentifier", "TADA.ResultMeasure.MeasureUnitCode", depths)