My goal is to create a binary variable (k) that turns 1 if in any column between mpg and wt the values 3.90 and/or 160.0 appears.
Code
library(tidyverse)
mtcars<-mtcars%>%
mutate(k=ifelse(mpg:wt==3.90|mpg:wt==160.0,1,0))
Result
Error in `mutate()`:
ℹ In argument: `k = ifelse(mpg:wt == 3.9 | mpg:wt == 160, 1, 9)`.
Caused by error:
! `k` must be size 32 or 1, not 19.