This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char_to_number <- function(x) { | |
# replace , with point | |
ret <- gsub(",", ".", x, fixed = TRUE) | |
# check for values that cannot be converted | |
na_start <- is.na(ret) | |
na_conversion <- is.na(suppressWarnings(as.numeric(ret))) | |
na_conversion <- na_conversion & !na_start | |
if (any(na_conversion)) { |