Reputation: 3
I have a very simple "ifelse" function that should include many "or" conditions and then simply assign a 1 or 0.
I tried changing the arguments.
dt.data[, new_variable:= ifelse(sic==2833|2834|2835|2836,1,0)]
Upvotes: 0
Views: 47
Reputation: 47320
2833|2834|2835|2836
is TRUE
so you're actually calling dt.data[, new_variable:= ifelse(sic== TRUE,1,0)]
Where you probably mean dt.data[, new_variable:= ifelse(sic %in% c(2833, 2834, 2835, 2836),1,0)]
Upvotes: 1