diff --git a/R/FeatureConstruction.R b/R/FeatureConstruction.R index 3687d2f77..489f3c0de 100644 --- a/R/FeatureConstruction.R +++ b/R/FeatureConstruction.R @@ -107,9 +107,9 @@ featureWindowsTempTableSql <- function(connection, featureWindows, oracleTempSch getAllFeatures <- function() { colNames <- c("name", "cohortId") # Use this to subset to the columns of interest cohortBasedStrata <- getCohortBasedStrata() - cohortBasedStrata <- cohortBasedStrata[, match(colNames, names(cohortBasedStrata))] + cohortBasedStrata <- cohortBasedStrata[, ..colNames] cohortBasedFeatures <- getFeatures() - cohortBasedFeatures <- cohortBasedFeatures[, match(colNames, names(cohortBasedFeatures))] + cohortBasedFeatures <- cohortBasedFeatures[, ..colNames] features <- rbind(cohortBasedStrata, cohortBasedFeatures) return(features) } diff --git a/R/ResourceFiles.R b/R/ResourceFiles.R index 0470479ab..3c6183c72 100644 --- a/R/ResourceFiles.R +++ b/R/ResourceFiles.R @@ -52,10 +52,10 @@ getCohortsToCreate <- function(cohortGroups = getCohortGroups()) { getAllStrata <- function() { colNames <- c("name", "cohortId", "generationScript") # Use this to subset to the columns of interest bulkStrata <- getBulkStrata() - bulkStrata <- bulkStrata[, match(colNames, names(bulkStrata))] + bulkStrata <- bulkStrata[, ..colNames] atlasCohortStrata <- getCohortBasedStrata() atlasCohortStrata$generationScript <- paste0(atlasCohortStrata$cohortId, ".sql") - atlasCohortStrata <- atlasCohortStrata[, match(colNames, names(atlasCohortStrata))] + atlasCohortStrata <- atlasCohortStrata[, ..colNames] strata <- rbind(bulkStrata, atlasCohortStrata) return(strata) } @@ -64,8 +64,8 @@ getAllStudyCohorts <- function() { cohortsToCreate <- getCohortsToCreate() targetStrataXref <- getTargetStrataXref() colNames <- c("name", "cohortId") - cohortsToCreate <- cohortsToCreate[, match(colNames, names(cohortsToCreate))] - targetStrataXref <- targetStrataXref[, match(colNames, names(targetStrataXref))] + cohortsToCreate <- cohortsToCreate[, ..colNames] + targetStrataXref <- targetStrataXref[, ..colNames] allCohorts <- rbind(cohortsToCreate, targetStrataXref) return(allCohorts) } @@ -82,12 +82,12 @@ getAllStudyCohortsWithDetails <- function() { cohortsToCreate$strataCohortId <- 0 cohortsToCreate$strataCohortName <- "All" cohortsToCreate <- dplyr::rename(cohortsToCreate, cohortName = "name") - cohortsToCreate <- cohortsToCreate[, match(colNames, names(cohortsToCreate))] + cohortsToCreate <- cohortsToCreate[, ..colNames] # Format - targetStrataXref stratifiedCohorts <- dplyr::inner_join(targetStrataXref, cohortsToCreate[,c("targetCohortId", "targetCohortName")], by = c("targetId" = "targetCohortId")) stratifiedCohorts <- dplyr::inner_join(stratifiedCohorts, allStrata[,c("cohortId", "name")], by=c("strataId" = "cohortId")) stratifiedCohorts <- dplyr::rename(stratifiedCohorts, targetCohortId="targetId",strataCohortId="strataId",cohortName="name.x",strataCohortName="name.y") - stratifiedCohorts <- stratifiedCohorts[,match(colNames, names(stratifiedCohorts))] + stratifiedCohorts <- stratifiedCohorts[,..colNames] # Bind allCohorts <- rbind(cohortsToCreate, stratifiedCohorts) return(allCohorts) diff --git a/R/RunStudy.R b/R/RunStudy.R index e662cb2cd..69643badb 100644 --- a/R/RunStudy.R +++ b/R/RunStudy.R @@ -225,7 +225,7 @@ runStudy <- function(connectionDetails = NULL, for(analysis in DistribAnalyses){ outcome <- gsub("TimeTo", "", analysis) outcome <- substring(SqlRender::camelCaseToTitleCase(outcome), 2) - outcomeId <- outcomes[tolower(outcomes$name) == tolower(outcome), "cohortId"] + outcomeId <- outcomes[tolower(outcomes$name) == tolower(outcome), "cohortId"][[1]] if (length(outcomeId) == 0 & analysis %in% outcomeBasedAnalyses){ next @@ -537,7 +537,7 @@ loadCohortsForExportFromPackage <- function(cohortIds) { strataId = NULL) cols <- names(cohorts) - cohorts <- rbind(cohorts, targetStrataXref[cols]) + cohorts <- rbind(cohorts, targetStrataXref[,..cols]) if (!is.null(cohortIds)) { cohorts <- cohorts[cohorts$cohortId %in% cohortIds, ] diff --git a/inst/shiny/PioneerWatchfulWaitingExplorer/server.R b/inst/shiny/PioneerWatchfulWaitingExplorer/server.R index 11a41072a..f5b47a86c 100644 --- a/inst/shiny/PioneerWatchfulWaitingExplorer/server.R +++ b/inst/shiny/PioneerWatchfulWaitingExplorer/server.R @@ -354,7 +354,6 @@ shinyServer(function(input, output, session) { getMetricsTable <- reactive ({ - browser() target_id <- cohortCount[cohortCount$databaseId %in% input$databasesMetricsDistribution & cohortCount$cohortId %in% cohortIdMetricsDistribution(), ][[1]] metricsTable <- metricsDistribution %>% dplyr::filter(cohortDefinitionId == target_id,