expandAllInconsistentFactorLevels: expandAllInconsistentFactorLevels

Description Usage Arguments Details Value Author(s) Examples

Description

expand a factor variables in all dataset to encompass levels of all sets

Usage

1
2
expandAllInconsistentFactorLevels(..., .noWarningCols = character(0), 
    .omitWarning = FALSE)

Arguments

...

list of data.frames or several data.frames separated by comma

.noWarningCols

string vector: do not warn for the these columns

.omitWarning

Details

If no data.frame is provided, its returns an empty list.

Instead of providing several arguments, one can provide a a single list of data.frames

Value

datasets with updated factor columns

Author(s)

Thomas Wutzler

Examples

1
2
3
4
5
6
7
8
if (exists("expandAllInconsistentFactorLevels")) {
  df1 <- data.frame(f = factor(c("D","D","C")))
  df2 <- data.frame(f = factor(c("C","C","A"))
                    , desc = c("forC1","forC2","forA1"))
  if (requireNamespace("dplyr"))
    dplyr::bind_rows(expandAllInconsistentFactorLevels(df1,df2))
  left_joinFactors(df1,df2)
}

bgctw/dplyrUtil documentation built on Nov. 11, 2020, 12:25 a.m.