Skip to contents

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)
#> [1] 10000.5