When trying to convert the text values of the columns of a data.frame
, created using Stringasfactor = FALSE
, numeric, I got an abnormal result by coercion:
> str(ccredito$Restaurantes)
chr [1:20] "49,74" "15,98" "59,4" "14" "57,42" "64,4" "15,4" "29,9" "28,22" "12" "63,25" ...
> colunanumerica <- as.numeric(ccredito$Restaurantes)
Warning message:
NAs introduced by coercion
> colunanumerica
[1] NA NA NA 14 NA NA NA NA NA 12 NA NA 6 NA NA NA NA 20 35 NA
How to correct and / or avoid this incorrect coercion?