I received some data recently in an Excel file. I opened it in LibreOffice Calc to have a quick look, saved it as a csv, and (tried) to get down to business in R. But all of my column names were an awful mess. Instead of
SPU_Number SPU_Name Long_Site Site
my column names were prepended with X.
and appended with a period, like so:
X.SPU_Number. X.SPU_Name. X.Long_Site. X.Site.
I’d used read.csv()
, which uses read.table()
. This stackoverflow answer clued me in to the fact that R thought there were special characters at the beginning and end of my column names. I reopened the file in LibreOffice Calc and annoying saw absolutely no special characters at the beginning and end of my column names. But when I opened up the file in a normal text editor I saw that my column names had all been single quoted!
To prevent this from happening to you, make sure you check Edit Filter Settings in the Save As dialogue and then make sure both Save cell content as shown and Quote all text cells are unchecked. Or don’t use LibreOffice Calc – Excel won’t screw up your column names like this.