I'm analysing survival data, and i am hoping to take a column of survival durations and calculate logical vectors based on a threshold of 1:24 - and put this together in a dataframe.
For example, take this sample data:
set.seed(1988)
test <- tibble(
survival = c(sample(1:40,10, replace =T))
)
I would like to rapidly create new columns titled "survival1","survival2" etc - up to "survival24" - with logical values based on whether survival > threshold.
As i'm most familiar with dplyr I've thus far been manually mutating e.g.
test %>% mutate(survival1 = survival > 1, survival2 = survival > 2)
But i thought there must be a better way!