as_num: Coerce character to numeric

View source: R/as_num.r

as_numR Documentation

Coerce character to numeric

Description

Coerce a character vector to numeric, by:

- Removing the thousand separator mark.
- Replacing decimal mark with a dot.
- Removing the character "$".
- Removing the characters from the alphabet.
- Trimming extra spaces.
- Applying the function as.numeric.

Usage

as_num(x, thousand_mark = "\\.", decimal_mark = "\\,")

Arguments

x

A character vector

thousand_mark

A character single value to use as the thousand mark (default = '\ \.')

decimal_mark

A character single value to use as the decimal mark (default = '\ \,')

Value

A numeric vector.

Examples


x <- "10.000,50"

as_num(x)


vbfelix/relper documentation built on May 10, 2024, 10:50 p.m.