How to get rid of <U+FEFF> in a R data.table column name? -
in order import large dataset i've used data.table option integer64 = "character" because columns have large numbers truncated otherwise, , identifiers.
my <- fread("mydata.csv", encoding="utf-8",integer64 = "character")
with option enabled columns imported characters have problem, columnnames have being automatically modified start these character
<u+feff>
for example first column called
<u+feff>id_2006_2011
the problem can't work names, example:
> minidt[1,"<u+feff>id_2006_2011", with=f] error in `[.data.table`(minidt, 1, "<u+feff>id_2006_2011", = f) : column(s) not found: <u+feff>id_2006_2011 > minidt[1,"id_2006_2011", with=f] error in `[.data.table`(minidt, 1, "id_2006_2011", = f) : column(s) not found: id_2006_2011
how can work them? how can change them simpler? i've tried
setnames(minidt, "id_2006_2011", "id")
but error:
error in setnames(minidt, "id_2006_2011", "id") : items of 'old' not found in column names: id_2006_2011
the column name there because...:
> minidt[1,1, with=f] <u+feff>id_2006_2011 1: 160701000002
for moment i'll using numbers instead of names refer columns.
Comments
Post a Comment