After recode from continuous variables into categorical. The summary for the new categorical variable doens't show how it summarize for categorical in levels we often see.
Please help!
After recode from continuous variables into categorical. The summary for the new categorical variable doens't show how it summarize for categorical in levels we often see.
Please help!
cut
does precisely this.
A4$resize <- cut(A4$Size, breaks = c(-Inf, 1000, Inf), labels = c("S", "L"))
We can use findInterval
A4$resize <- with(A4, c('S', 'L')[findInterval(Size, 1000)])
Or using case_when
library(dplyr)
A4 %>%
mutate(resize = case_when(Size > 1000 ~ "S", TRUE ~ "L"))