Как подсказывает @ r2evans, используйте cut
. Вот воспроизводимый пример в контексте вашего вопроса:
set.seed(1) #make results reproducible.
sector <- data.frame(mini.sector = seq(1,10,1), value = round(runif(10, 1, 100), 0))
#name macro sectors as 'a', 'b', 'c' and 'n' and assign them to micro sectors based on defined value cuts.
sector$macro.sector <- cut(sector$value, c(-Inf, 10, 25, 50, Inf), labels=c("a", "b", "c", "n"))
head(sector) #show first five row from data frame 'sector'.
mini.sector value macro.sector
1 27 c
2 38 c
3 58 n
4 91 n
5 21 b
6 90 n