I want to replace NA with other value for specific column in data.table. I tried below link but some error shows up.
How to replace NA values in a table for selected columns? data.frame, data.table
The codes that I use are
df<-data.table(aa<-(1:4),ba<-c(NA,1,3,4),ca<-c(NA,"2012-01-02","2012-02-02","2012-03-02"))
df[is.na(get(ca)),(ca):="2012-04-01"]
I got the error message: Error in get(c) : object 'NA' not found
But if I use
df[is.na(ca),(ca):="2012-04-01"]
It returns results that I don't want.
Can anyone help me?
Thanks