as_mon_numeric {thinkr}R Documentation

Transform a vector into numeric if meaningful, even with bad decimal, space or %

Description

Transform a vector into numeric if meaningful, even with bad decimal, space or %

Usage

as_mon_numeric(vec)

Arguments

vec

a vector

Details

Note that text and factors are not transformed as numeric (except FALSE, TRUE, F, T), contrary to R default behavior with 'as.numeric(factor())'

Value

a numeric vector

Examples

as_mon_numeric(c("1", "0", "1"))
as_mon_numeric(c("1.3", "1,5", "1;6", "16%", "17 87 "))
as_mon_numeric(c(TRUE, "A", "F"))
as_mon_numeric(c(TRUE, TRUE, FALSE))
as_mon_numeric(factor(c("toto", "tata", "toto")))

[Package thinkr version 0.16 Index]