keep_numeric: Keep numeric elements in a string

Description Usage Arguments Examples

Description

Keep numeric elements in a string

Usage

1
2
keep_numeric(column, na_labels = NULL, max_value = NULL, min_value = NULL,
  comma = FALSE)

Arguments

column

column from a survey data frame where numbers are included with units or other test, such as "15 years old".

na_labels

An explicit missing label to be removed such as "refusal". The default value is NULL, but "default" will use a setting c("refusal", "nt/nv", "dk", "dk/na") and remove all observations starting with a label Inap..

max_value

Optional maximum value, anything reaching this level will be replaced with NA.

min_value

Optional maximum value, anything reaching this level will be replaced with NA.

comma

If decimals are written with commas, such as 10,7 instead of 10.7 Defaults to FALSE.

Examples

1
2
3
4
5
keep_numeric("He is 183.5 cm tall")

keep_numeric("He is 183,5 cm tall", comma=TRUE)

keep_numeric("He is 383.5 cm tall", max_value = 250)

antaldaniel/surveyreader documentation built on May 16, 2019, 2:29 a.m.