executeLeftJoinPlan(
  tDesc,
  columnJoinPlan,
  ...,
  checkColumns = FALSE,
  computeFn = function(x, name) {     dplyr::compute(x, name = name) },
  eagerCompute = TRUE,
  checkColClasses = FALSE,
  verbose = FALSE,
  dryRun = FALSE,
  tempNameGenerator = mk_tmp_name_source("executeLeftJoinPlan")
)

Arguments

tDesc

description of tables, either a data.frame from tableDescription, or a list mapping from names to handles/frames. Only used to map table names to data.

columnJoinPlan

columns to join, from buildJoinPlan (and likely altered by user). Note: no column names must intersect with names of the form table_CLEANEDTABNAME_present.

...

force later arguments to bind by name.

checkColumns

logical if TRUE confirm column names before starting joins.

computeFn

function to call to try and materialize intermediate results.

eagerCompute

logical if TRUE materialize intermediate results with computeFn.

checkColClasses

logical if true check for exact class name matches

verbose

logical if TRUE print more.

dryRun

logical if TRUE do not perform joins, only print steps.

tempNameGenerator

temp name generator produced by wrapr::mk_tmp_name_source, used to record dplyr::compute() effects.

Value

joined table

See also

Examples

# example data meas1 <- data.frame(id= c(1,2), weight= c(200, 120), height= c(60, 14)) meas2 <- data.frame(pid= c(2,3), weight= c(105, 110), width= 1) # get the initial description of table defs tDesc <- rbind(tableDescription('meas1', meas1), tableDescription('meas2', meas2)) # declare keys (and give them consitent names) tDesc$keys[[1]] <- list(PatientID= 'id') tDesc$keys[[2]] <- list(PatientID= 'pid') # build the column join plan columnJoinPlan <- buildJoinPlan(tDesc) # decide we don't want the width column columnJoinPlan$want[columnJoinPlan$resultColumn=='width'] <- FALSE # double check our plan if(!is.null(inspectDescrAndJoinPlan(tDesc, columnJoinPlan, checkColClasses= TRUE))) { stop("bad join plan") } # execute the left joins executeLeftJoinPlan(tDesc, columnJoinPlan, checkColClasses= TRUE, verbose= TRUE)
#> [1] "start meas1 Sun Sep 6 14:10:03 2020" #> [1] " rename/restrict meas1" #> [1] " 'PatientID' = 'id'" #> [1] " 'meas1_weight' = 'weight'" #> [1] " 'height' = 'height'" #> [1] " res <- meas1" #> [1] "done meas1 Sun Sep 6 14:10:03 2020" #> [1] "start meas2 Sun Sep 6 14:10:03 2020" #> [1] " rename/restrict meas2" #> [1] " 'table_meas2_present' = 'table_meas2_present'" #> [1] " 'PatientID' = 'pid'" #> [1] " 'meas2_weight' = 'weight'" #> [1] " res <- left_join(res, meas2," #> [1] " by = c( 'PatientID' ))" #> [1] "done meas2 Sun Sep 6 14:10:03 2020"
#> PatientID meas1_weight height table_meas2_present meas2_weight #> 1 1 200 60 0 NA #> 2 2 120 14 1 105
# also good executeLeftJoinPlan(list('meas1'=meas1, 'meas2'=meas2), columnJoinPlan, checkColClasses= TRUE, verbose= TRUE)
#> [1] "start meas1 Sun Sep 6 14:10:03 2020" #> [1] " rename/restrict meas1" #> [1] " 'PatientID' = 'id'" #> [1] " 'meas1_weight' = 'weight'" #> [1] " 'height' = 'height'" #> [1] " res <- meas1" #> [1] "done meas1 Sun Sep 6 14:10:03 2020" #> [1] "start meas2 Sun Sep 6 14:10:03 2020" #> [1] " rename/restrict meas2" #> [1] " 'table_meas2_present' = 'table_meas2_present'" #> [1] " 'PatientID' = 'pid'" #> [1] " 'meas2_weight' = 'weight'" #> [1] " res <- left_join(res, meas2," #> [1] " by = c( 'PatientID' ))" #> [1] "done meas2 Sun Sep 6 14:10:03 2020"
#> PatientID meas1_weight height table_meas2_present meas2_weight #> 1 1 200 60 0 NA #> 2 2 120 14 1 105