Remove accents from a dataframe column in R

前端 未结 4 1227
感情败类
感情败类 2021-02-05 04:03

I got a data.table base. I got a term column in this data.table

class(base$term)
[1] character
length(base$term)
[1] 27486

I\'m able to remove

4条回答
  •  借酒劲吻你
    2021-02-05 04:25

    It might be easier to use the stringi package. This way, you don't need to check the encoding beforehand. Furthermore stringi is consistent across operating systems and inconv is not.

    library(stringi)
    
    base <- data.table(terme = c("Millésime", 
                                 "boulangère", 
                                 "üéâäàåçêëèïîì"))
    
    base[, terme := stri_trans_general(str = terme, 
                                       id = "Latin-ASCII")]
    
    > base
               terme
    1:     Millesime
    2:    boulangere
    3: ueaaaaceeeiii
    

提交回复
热议问题