prep_numeric_caps: prep_numeric_caps

Description Usage Arguments Value Examples

View source: R/prep_numeric_caps.R

Description

prep_numeric_caps

Usage

1
2
3
4
5
6
7
prep_numeric_caps(
  data,
  cap_below = NULL,
  cap_above = NULL,
  unknown_below = NULL,
  unknown_above = NULL
)

Arguments

data

vector or dataframe - data to cap. For dataframe columns are encoded. All columns must be numeric

cap_below

numeric or named list of numerics. Is the lower value at which to cap If a named list is given the names must be the same as the dataframe colnames

cap_above

numeric or named list of numerics. Is the upper value at which to cap If a named list is given the names must be the same as the dataframe colnames

unknown_below

numeric or named list of numerics. Is the lower value at which to treat all below as unknown If a named list is given the names must be the same as the dataframe colnames

unknown_above

numeric or named list of numerics. Is the upper value at which to treat all above as unknown If a named list is given the names must be the same as the dataframe colnames

Value

output the same shape as data with capping performed

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
prep_numeric_caps(0:10, cap_below=3, unknown_above=7)


data_in_df <- data.frame(
  first=seq(0,10,1),
  second=seq(0,100,10),
  third=seq(0,10,1)
)

cap_below <- list(first=3, second = 30, third=NULL)
cap_above <- list(first=7, second = 70, third=NULL)
unknown_below <- list(first=1, second = 10, third=NULL)
unknown_above <- list(first=9, second = 90, third=NULL)

prep_numeric_caps(data=data_in_df, cap_below=cap_below, cap_above=cap_above, unknown_below=unknown_below, unknown_above=unknown_above)

gloverd2/admr documentation built on Dec. 2, 2020, 11:16 p.m.