0

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)]
markus
  • 25,843
  • 5
  • 39
  • 58

1 Answers1

1

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)]

moodymudskipper
  • 46,417
  • 11
  • 121
  • 167