I'm trying to do the folowing using dplyr
:
Suppose you have the data.frame
y
and you want to create a new variable based on values of var1
y <- data.frame(var1 = rnorm(100))
y$var2 <- 0
y$var2[y$var1 > 0.5] <- 1
Is it possible to do this using dplyr
's mutate
and filter
?