Replacing commas and dots in R

前端 未结 3 1361
名媛妹妹
名媛妹妹 2020-12-28 17:25

I have a whole column of numbers that include dot separators at the thousands and comma instead of dot as an dismal separator. When I try to create a numeric column out of t

3条回答
  •  Happy的楠姐
    2020-12-28 18:04

    You can use function "type_convert", from "readr" package. I am reading an ODS file (Locale Portuguese), and converting the numbers:

    library('readODS')
    library('tidyverse')
    data <- read_ods('mod-preditivo.ods', sheet=1,col_names = TRUE,range='a1:b30',col_types=NA)
    df <- type_convert(data,trim_ws=TRUE,col_types = cols(Pesos=col_integer(),Alturas=col_double()),locale = locale(decimal_mark = ","))
    str(df)
    

提交回复
热议问题