I have a dataset in R tidyverse and I want to create 192 columns based on comparison with the sp column, just like the mp_comp_1 column. How can I do this for 192 columns in tidyverse?
library(tidyverse)
df <- data.frame(matrix(ncol = 4, nrow = 3))
df%>%
mutate(sp = c(34.9, 34.3, 34.4)) %>%
mutate(mp_1 = c(35, 32.1, 34.4)) %>%
mutate(mp_2 = c(30, 38.1, 39.4)) %>%
mutate(mp_192 = c(34.9, 34.3, 30.4)) %>%
select(sp, mp_1, mp_2, mp_192) %>%
mutate(mp_comp_1= if_else(mp_1>sp, "bigger",
if_else(mp_1<sp, "smaller", "equal")))