franken_prop: Combine a property from all components of a 'franken_xpdb'

View source: R/xset_plots.R

franken_propR Documentation

Combine a property from all components of a franken_xpdb

Description

Combine a property from all components of a franken_xpdb

Usage

franken_prop(
  xpdb_f,
  xpdb_list,
  prop,
  problem = NULL,
  glue_cmd = function(x) glue::glue_collapse(x, ", ", last = " and "),
  indices = seq_along(xpdb_list)
)

Arguments

xpdb_f

A product of franken_xpdb

xpdb_list

List of the source xpose_data objects.

prop

<character> of the property to combine

problem

<numeric> If necessary to specify

glue_cmd

Any special transformation to the properties, including how to collapse.

indices

<numeric> Index values 1:length(xpdb_list) to include in the property collapse.

Details

This function is meant to be called within franken_xpdb. It is expected to be ready to handle cases where, for example, multiple props are being set in a pipe, or a problem-associated property is being set while a problem=0 property is also being set.

This is a low-level function, so its use outside of internal functions is not intended.

Value

Same as xpdb_f with new properties.

Examples


# This is designed to be called in a function environment which
# would provide something like the following:

xpdb_f <- franken_xpdb(pheno_base, pheno_final, .types="catcov")

xpdb_list <- list(pheno_base, pheno_final)

# The following would be inside the function
xpdb_f %>%
  franken_prop(xpdb_list, "run",
    glue_cmd = function(x) paste(x, collapse="+"))

# xpdb_f may have to be written to a few times if
# and problem-specific combinations are needed:

updated <- xpdb_f %>%
  franken_prop(xpdb_list, "run",
    glue_cmd = function(x) paste(x, collapse="+"))

# problem will also be available. Assume there's
# no reason to loop here, but that may be needed
problem <- 1
updated <- updated %>%
  franken_prop(xpdb_list, "ofv",  problem=problem,
    glue_cmd = function(x) paste(x, collapse="&"))


xpose.xtras documentation built on April 4, 2025, 2:13 a.m.