R: read.csv adding sub-script "X" in header
23,265
Solution 1
according to @Joshua
read.csv("filename.csv",check.names=FALSE)
Solution 2
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.
Solution 3
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.
Related videos on Youtube
Comments
-
Rachit Agrawal almost 2 years
I have a data frame that has headers as this
Name 0x1 1x2
read.csv changes the header to be
Name X0x1 X1x2
Is there a way, where this can be avoided?
Thanks.
-
Joshua Ulrich almost 11 yearsRead
?read.csv
, where it describes thecheck.names
argument. -
Roland almost 11 yearsAnd be warned that there are good reasons that
read.table
and friends sanitize the names.
-
-
Super_John almost 6 yearssomeone please tell me why that worked. I've spend 2 hours on this and 20 stack overflow postings. This is insane.