The variable Recence_Connexion_Jrs
is composed of "NA" and some figures (from 1 to 100), and I'm trying to make the "NA" equal to "No Open", and also cut the figures into 3 groups, and the labels of the groups are in the type of string.
For example:
Recence_Connexion_Jrs Connexion
NA No open
NA No open
NA No open
1 connexion 0-7
10 connexion 7-30
The code that I used:
setDT(newdata)[!duplicated(newdata),Connexion:=ifelse(is.na(Recence_Connexion_jrs),
"No Open",cut(Recence_Connexion_jrs,breaks=c(-Inf,7,30,+Inf),
labels=c("connexion 0-7","connexion 7-30","connexion 30+")))]
But it gave the wrong result.
How can I solve that?