Categorize numeric variable into group/ bins/ breaks
I would use findInterval() here: First, make up some sample data set.seed(1) ages <- floor(runif(20, min = 20, max = 50)) ages # [1] 27 31 37 47 26 46 48 39 38 21 26 25 40 31 43 34 41 49 31 43 Use findInterval() to categorize your “ages” vector. findInterval(ages, c(20, 30, 40)) … Read more