I am writing a function where multiple ifelse are being used for data table operation. Although I am using data tables for speed but multiple ifelse making my code slow and this function is for large data set. Hence I was wondering if there is an alternative to iflese. One example iflese from the function(there are close to 15 iflese ), in this example flag is set to 1 if x is blank else 0.
dt<-dt[,flag:=ifelse((is.na(x)|!nzchar(x),1,0)]
My apologies if this is a duplicate question.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire