This works like is.double() and as.double(), but is vectorised and can also check (and transform) comma-decimal input such as "0,1".

is.double2(x, dec = c(".", ","))

as.double2(x, dec = c(".", ","))

Arguments

x

vector of values

dec

characters to be treated as comma

Examples

is.double(0.1)
#> [1] TRUE
is.double("0.1")
#> [1] FALSE
is.double("0,1")
#> [1] FALSE

is.double2(0.1)
#> [1] TRUE
is.double2("0.1")
#> [1] TRUE
is.double2("0,1")
#> [1] TRUE

is.double(c(0.1, "0.1", "0,1"))
#> [1] FALSE
is.double2(c(0.1, "0.1", "0,1"))
#> [1] TRUE TRUE TRUE

as.double(c(0.1, "0.1", "0,1"))
#> Warning: NAs introduced by coercion
#> [1] 0.1 0.1  NA
as.double2(c(0.1, "0.1", "0,1"))
#> [1] 0.1 0.1 0.1