If I want to recode a variable in R using data.table, what is the syntax? I saw some ans but didn\'t find them appropriate.
data.table
e.g. if I have the variable cal
Put the rules in a table and do an update join:
gmap = data.table(old = 0:2, new = c("Unknown", "Male", "Female")) trips[, Gender := gmap[copy(.SD), on=.(old = Gender), x.new]] Name Gender 1: John Male 2: Tina Female 3: Dave Female 4: Casper Unknown