Importing an Excel file with Greek characters into R in the correct encoding

后端 未结 2 1526
南笙
南笙 2020-12-18 04:37

I am having some trouble importing the following file: http://www.kuleuven.be/bio/ento/temp/test.xlsx into R in the correct encoding. In particular,

library(         


        
相关标签:
2条回答
  • 2020-12-18 05:16

    Try this:

    library(stringi)

    ?stringi
    

    Apply this to see your file codification

    stri_enc_detect("path-to-your-file/your-file.csv", filter_angle_brackets = T)
    
    stri_enc_detect2("path-to-your-file/your-file.csv", locale = NULL)
    

    The first one works for me.

    Then apply the result in the read.csv(), as the example bellow:

        df <- read.csv("path-to-your-file/your-file.csv",header = TRUE, sep = ";", 
    quote = "\"", na.strings = "", dec = ".", skip = 2, check.names = T, 
    fileEncoding = "YOUR RESULT OF stri_enc_detect", encoding = "UTF-8")
    
    0 讨论(0)
  • 2020-12-18 05:39

    Try this:
    Sys.setlocale(category = "LC_ALL", locale = "Greek")

    0 讨论(0)
提交回复
热议问题