[datatable-help] Replace a character in one data table column
Frank S.
f_j_rod at hotmail.com
Tue Jul 29 18:28:09 CEST 2014
Hi everyone, I would want to replace only the "missing" characters in date column by "2002-06-30" character (I will make the change to date format in future): DT <- data.table(id=c(1,1,4,4,4), date=as.character(c("1997-04-26","missing","1998-08-25","missing","1998-11-07")))DT id date1: 1 1997-04-262: 1 NA3: 4 1998-08-254: 4 NA5: 4 1998-11-07 DT[,list(id, date=if(variable==NA) {"2002-06-30"} else date)] But I get an error message. Is it posible to do it under data table format? Many thanks to all the data.table help members!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20140729/9acc80c1/attachment.html>
More information about the datatable-help
mailing list