When reading in a data file into R, I can read it in either as a data.frame
or a data.table
using the data.table
package. I would prefer to use data.table
in the future since it deals with large data better. However, there are issues with both methods (read.table
for data.frames, fread
for data.tables) and I'm wondering if there's a simple fix out there.
When I use read.table
to produce a data.frame
, if my column names include colons or spaces, they are replaced by periods, which I do not want. I want the column names to be read in "as is."
Alternatively, when I use fread
to produce a data.table
, my column names are not read in at all, which is obviously not desired.
Check out this gist below for a reproducible example:
https://gist.github.com/jeffbruce/b966d41eedc2662bbd4a
Cheers