Skip to contents

Gets vector by column and defactor if needed. Optionaly one can provide a fallback_value which will be returned if col is not specified.

Usage

get_vector(
  x,
  col,
  rows = NULL,
  choices = NULL,
  fallback_value = NULL,
  fallback_value_supersedes = FALSE,
  fallback_value_any_missing = TRUE,
  fallback_value_ensure_length = TRUE,
  check_x_col_rows = TRUE,
  which_call_to_report = -1L
)

Arguments

x

Input data. Can be vector, data.frame or a data.table

col

Column of interest in the input data x. The vector we would like to work with. Ignored if input x is a atomic vector.

rows

Rows of interest

choices

Optional set of choices that return value should be subset of. Do no check if it is NULL.

fallback_value

If col is NULL then return this value (but see fallback_value_supersedes argument). Also check if it is a character vector and same lenght as x. If it is of length 1 then replicate it to match x's length.

fallback_value_supersedes

A bolean toggle. When set col is ignored when fallback_value is provided. Otherwise (the default) if col is provided then fallback_value is ignored.

fallback_value_any_missing

Toggle check if missing values are allowed in fallback_value

fallback_value_ensure_length

Toggle if fallback_value should we make it same length as x

check_x_col_rows

Toggle wheather to use check_x, check_col, check_rows?

which_call_to_report

Which call to report if argument checks fail.

Value

A vector. Factors in imput data are converted to string.