I have a data.table with columns A, B and C
A | B | C
1 | 1 | 2
2 | 1 | 2
2 | 3 | 1
I want to change the values of each column to "True" (if the row value == 2) or "False" otherwise, programmatically.
I know that dt[, A := fifelse(A == 2, "True", "False"]
works, but how do I pass in the columns as a variable? Something like dt[, cols := fifelse(cols := 2, "True", "False"]
, where cols = "A"