extract_code: Extract a code component

extract_codeR Documentation

Extract a code component

Description

This uses a regular expression to get a code from beging of a character string. Useful to extract names from code-name variables.

Usage

extract_code(x, numbers_as_numeric = TRUE)

Arguments

x

A character vector (or a factor).

numbers_as_numeric

A locigal. Whether to try to convert a code to a numeric.

Value

A character vector (or a factor).

See Also

extract_name

Examples

 extract_code("508 Mantta-Vilppula")
 extract_code("508 Mantta-Vilppula", numbers_as_numeric = FALSE)

pttry/statfitools documentation built on Feb. 2, 2025, 1:50 a.m.