Skip to content
Prev 391912 / 398500 Next

Create a categorical variable using the deciles of data

I want Create a categorical variable using the deciles of the
following data frame to divide the individuals into 10 groups equally.
I try the following codes
data_catigocal<-data.frame(c(1:50000))
# create categorical vector using deciles
group_vector <-
c('0-10','11-20','21-30','31-40','41-50','51-60','61-70','71-80','81-90','91-100')
# Add categorical variable to the data_catigocal
data_catigocal$decile <- factor(group_vector)
# print data frame
data_catigocal

can any one help me with the r code
Kind regards,
Hana