Why are Xs added to data frame variable names when using read.csv?

前端 未结 3 834
南笙
南笙 2020-12-25 12:28

When I use the read.csv() function in R to load data, I often find that an X has been added to variable names. I think I just about always see it

3条回答
  •  长情又很酷
    2020-12-25 13:12

    read.table and read.csv have a check.names= argument that you can set to FALSE.

    For example, try it with this input consisting of just a header:

    > read.csv(text = "a,1,b")
    [1] a  X1 b 
    <0 rows> (or 0-length row.names)
    

    versus

    > read.csv(text = "a,1,b", check.names = FALSE)
    [1] a 1 b
    <0 rows> (or 0-length row.names)
    

提交回复
热议问题