I'm trying to create a grouping variable with values 0 and 1 by splitting the columns.
For example Var1
would take the value 0 and Var2
would take the value 1.
Var1 <- c(12, 12.3, 14.1, 6.2, 2.9, 5, 16.2, 2.3, 4.8, 5.9, 15, 12, 11.1)
Var2 <- c(11.2, 15.1, 16, 7.2, 3.1, 1.2, 5.2, 4.1, 3.1, 11.6, 2.1, 6.5, 9.1)
data <- data.frame(Var1, Var2)
Looking to do this using a base R way and a tidyverse way