fct_num_range: Parse and re-level ambiguous numerical range factors

View source: R/parse_num_range.R

fct_num_rangeR Documentation

Parse and re-level ambiguous numerical range factors

Description

By default, fct_num_range() returns the re-leveled factor

Usage

fct_num_range(x, .range_sep = " - ", .return = "factor")

Arguments

.range_sep

A string which separates the two halves of the numeric range

.return

A string ("factor" or "table") indicating the function output

.fctr

A factor or atomic vector that can be coerced into a factor

Details

This function takes a factor and typically returns the same but re-leveled so that ambiguous numeric ranges (e.g. less than 10, 11-15, 16-20, more than 20) are ordered correctly as factor levels. The function can also be directed to return a table with the full level parsing, including upper and lower boundaries. This useful in complex cases where this parser is insufficient. The function also removes any currency symbols and thousands separators. It is localized for US - North America where "," is the thousands separator and "." is the decimal separator.

Value

Either the input factor re-leveled or the table of levels parsed into columns


cmstillwell/UWparserrr documentation built on Nov. 11, 2024, 10:38 p.m.