I have a data frame that has headers as this
Name 0x1 1x2
read.csv changes the header to be
Name X0x1 X1x2
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.
read_csv('file_name.csv",check,names=F)
check.names=F, strips the white space character and removes the "x"
according to @Joshua
read.csv("filename.csv",check.names=FALSE)
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.
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.