R: read.csv adding sub-script “X” in header

前端 未结 5 2046
眼角桃花
眼角桃花 2021-02-18 21:33

I have a data frame that has headers as this

Name  0x1  1x2

read.csv changes the header to be

Name X0x1 X1x2

相关标签:
5条回答
  • 2021-02-18 21:52

    I met the same problem. The solution for me on MAC machine is to save the file with fileEncoding = "macintosh". Then read it by doing check.names = F.

    0 讨论(0)
  • 2021-02-18 21:56
    read_csv('file_name.csv",check,names=F)
    

    check.names=F, strips the white space character and removes the "x"

    0 讨论(0)
  • 2021-02-18 22:05

    according to @Joshua

    read.csv("filename.csv",check.names=FALSE)
    
    0 讨论(0)
  • 2021-02-18 22:17

    I had the same issue on my Mac. There was a X... at the beginning of the first variable. The problem was that the CSV file was actually a CSV UTF-8 (Comma delimited) file. Saving the file as a CSV (Comma separated values) solved it.

    0 讨论(0)
  • 2021-02-18 22:18

    Using the quote="" option will also prepend an X. for each column of your data.frame. If you can, try to remove that from your read.csv options, else add the check.names=F option which will override that behavior.

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