I have a csv file where column names include spaces and special characters.
fread
imports them with quotes - but how can I change this behaviour? One reason is that I have column names starting with a space and I don't know how to handle them.
Any pointers would be helpful.
Edit: An example.
> packageVersion("data.table")
[1] ‘1.8.8’
p2p <- fread("p2p.csv", header = TRUE, stringsAsFactors=FALSE)
> head(p2p[,list(Principal remaining)])
Error: unexpected symbol in "head(p2p[,list(Principal remaining"
> head(p2p[,list("Principal remaining")])
V1
1: Principal remaining
> head(p2p[,list(c("Principal remaining"))])
V1
1: Principal remaining
What I was expecting/want is of course, what a column name without spaces yields:
> head(p2p[,list(Principal)])
Principal
1: 1000
2: 1000
3: 1000
4: 2000
5: 1000
6: 4130