Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #1636 allows Visualize_Metric() to run on just results #1833

Merged
merged 19 commits into from
Sep 23, 2024
Merged
Changes from 6 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
34 changes: 23 additions & 11 deletions R/Visualize_Metric.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Visualize_Metric <- function(
dfResults$SnapshotDate <- as.Date(Sys.Date())
}

if (!"SnapshotDate" %in% colnames(dfBounds)) {
if (!"SnapshotDate" %in% colnames(dfBounds) & !is.null(dfBounds)) {
dfBounds$SnapshotDate <- as.Date(Sys.Date())
}

Expand Down Expand Up @@ -80,15 +80,23 @@ Visualize_Metric <- function(
cli::cli_abort("Multiple MetricIDs found in dfResults, dfBounds or dfMetrics. Specify `MetricID` to subset. No charts will be generated.")
return(NULL)
}

# Prep chart inputs ---------------------------------------------------------
lMetric <- as.list(dfMetrics)
vThreshold <- ParseThreshold(lMetric$Threshold)
if(is.null(dfMetrics)){
lMetric <- NULL
vThreshold <- NULL
} else {
lMetric <- as.list(dfMetrics)
vThreshold <- ParseThreshold(lMetric$Threshold)
}

# Cross-sectional Charts using most recent snapshot ------------------------
lCharts <- list()
dfResults_latest <- FilterByLatestSnapshotDate(dfResults, strSnapshotDate)
dfBounds_latest <- FilterByLatestSnapshotDate(dfBounds, strSnapshotDate)
if(is.null(dfBounds)) {
dfBounds_latest <- NULL
} else{
dfBounds_latest <- FilterByLatestSnapshotDate(dfBounds, strSnapshotDate)
}

if (nrow(dfResults_latest) == 0) {
cli::cli_alert_warning("No data found for specified snapshot date: {strSnapshotDate}. No charts will be generated.")
Expand Down Expand Up @@ -133,12 +141,16 @@ Visualize_Metric <- function(
strType = "Score",
vThreshold = vThreshold
)

lCharts$metricTable <- Report_MetricTable(
dfResults = dfResults_latest,
dfGroups = dfGroups,
strGroupLevel = lMetric$GroupLevel
)
if(!is.null(dfGroups)) {
lCharts$metricTable <- Report_MetricTable(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lauramaxwell do you know if Report_MetricTable() is meant to be one of the visualizations that can be rendered with just results? If so, I think I need to make some modifications there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, although we should always have participant counts. Still if it's not too much effort this is a good candidate to optionalize group metadata.

dfResults = dfResults_latest,
dfGroups = dfGroups,
strGroupLevel = unique(dfGroups$GroupLevel)
)
}
else {
cli_inform("Group Metric Table was not rendered")
}
}
# Continuous Charts -------------------------------------------------------
if (number_of_snapshots <= 1) {
Expand Down