I have a dataframe:
dat <- data.frame(col1 = sample(0:3, 10, replace = TRUE),
col2 = sample(0:3, 10, replace = TRUE),
col3 = sample(0:3, 10, replace = TRUE),
col4 = sample(0:3, 10, replace = TRUE))
I want to create a new vector (outside of the dataframe) var that will state 1 if the sum of col3 and col4 is >= 4 and 0 otherwise. How can I do this? I tried using sum within an ifelse statement but it seems to produce a character output.
Any leads? Thanks!