Description Usage Arguments Value Examples
View source: R/utilities-data-validation.R
For numeric types, checks if x is in rng = (min, max) and censors values to either min or max if it is out of the range. For categorical types, values not in 'levels' are coded NA.
1 | censorData(x, varType, rng = NULL, levels = NULL, rngFormat = NULL)
|
x |
A vector of numeric or categorial values to censor. |
varType |
Character indicating the variable type of |
rng |
For x that is a numeric vector, a vector (min, max) of the bounds of the range. For input x that is a numeric matrices or dataframe with n columns, a list of (min, max) bounds of length n. |
levels |
For categorical types, a vector containing the levels to be returned. |
rngFormat |
For numeric types, a string describing the format of the range input. One of either 'vector' for x that is a numeric vector and rng that is a (min, max) tuple, or 'list' for x that is a numeric matrix or dataframe with n columns and rng that is a list of (min, max) bounds of length n. |
Original vector with values outside the bounds censored to the bounds.
1 2 | censorData(x=1:10, varType='integer', rng=c(2.5, 7))
censorData(x=c('a', 'b', 'c', 'd'), varType='character', levels=c('a', 'b', 'c'))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.