number_parsers: Convert character vectors to numeric vectors.

strip_alphaR Documentation

Convert character vectors to numeric vectors.

Description

Given a character vector, these function will strip non-numeric characters from each item and then attempt to convert the result to either a double using as.double() or an integer using as.integer().

Usage

strip_alpha(x)

parse_double(x)

parse_integer(x)

Arguments

x

The character vector to convert.

Value

For parse_double and parse_integer a vector only containing doubles or integers. The helper function strip_alpha removes all non-numeric values leaving only numbers, dots (. for decimals), and hyphens (- for negative values). The parsers will fail if strip_alpha yields something non-numeric looking, like "1.1.1".


UCLATALL/CourseKataData documentation built on Dec. 4, 2023, 2:25 a.m.