[R] Create a categorical variable using the deciles of data

anteneh asmare h@n@tezer@ @end|ng |rom gm@||@com
Tue Jun 14 13:28:37 CEST 2022


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



More information about the R-help mailing list