verbose_coerce: Coerce/convert data verbosely if NA is introduced by coercion

View source: R/verbose_coerce.R

verbose_coerceR Documentation

Coerce/convert data verbosely if NA is introduced by coercion

Description

Coerce/convert a given x using the coercer function; if a warning is raised and a difference in NA cardinality is present a report of NA produced by coercion is printed, with optional rows id printed

Usage

verbose_coerce(
  x,
  coercer,
  xname = NULL,
  varname_msg = TRUE,
  row_id = NULL,
  df_name = ""
)

Arguments

x

vector to be converted

coercer

a function (tipically as.*)

xname

string used for progress (varname) printing

varname_msg

logical: print progress (varname and optionally source)?

row_id

vector or data.frame used to identify the coerced rows (for reporting purposes in case of issues)

df_name

character with data.frame name for reporting purposes (where does the variable come from?)

Examples

## Not run: 
verbose_coerce(c("a", 2L, 3L), as.integer)
verbose_coerce(c("a", 2L, 3L), as.integer, row_id = letters[1:3])

## End(Not run)


lbraglia/lbmisc documentation built on March 28, 2024, 10:03 a.m.