Cannot read unicode .csv into R

后端 未结 3 1207
无人共我
无人共我 2020-11-30 07:29

I have a .csv file, which contains the following data:

\"Ա\",\"Բ\"
1,10
2,20

I cannot read it into R so that the column names are displayed

3条回答
  •  盖世英雄少女心
    2020-11-30 08:11

    I tried two ways to replicate your problem.

    I copied the characters above into RStudio, saved it to a csv with this code:

    write.csv(c("Ա","Բ",
                 1,10,
                 2,20), "test.csv")
    
    df <- read.csv("test.csv")
    

    This worked fine.

    Then I thought, well maybe R is cheating when I save it to CSV with R? So I just pasted the characters to a text file and save it as a CSV. This approach doesn't have problems either.

    Here's my session info:

    sessionInfo()
    R version 3.0.1 (2013-05-16)
    Platform: x86_64-pc-linux-gnu (64-bit)
    
    locale:
    [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C               LC_TIME=en_CA.UTF-8       
    [4] LC_COLLATE=en_CA.UTF-8     LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8   
    [7] LC_PAPER=C                 LC_NAME=C                  LC_ADDRESS=C              
    [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       
    
    attached base packages:
    [1] stats4    grid      stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] party_1.0-9       modeltools_0.2-21 strucchange_1.4-7 sandwich_2.2-10   zoo_1.7-10       
    [6] GGally_0.4.4      reshape_0.8.4     plyr_1.8          ggplot2_0.9.3.1  
    
    loaded via a namespace (and not attached):
    [1] coin_1.0-23        colorspace_1.2-2   dichromat_2.0-0    digest_0.6.3      
    [5] gtable_0.1.2       labeling_0.2       lattice_0.20-23    MASS_7.3-29       
    [9] munsell_0.4.2      mvtnorm_0.9-9995   proto_0.3-10       RColorBrewer_1.0-5
    [13] reshape2_1.2.2     scales_0.2.3       splines_3.0.1      stringr_0.6.2 
    

提交回复
热议问题