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

Richard O'Keefe r@oknz @end|ng |rom gm@||@com
Tue Jun 14 15:07:47 CEST 2022


Can you explain why you are not using
?quantile
to find the deciles then
?cut
to construct the factor?
What have I misunderstood?

On Tue, 14 Jun 2022 at 23:29, anteneh asmare <hanatezera using gmail.com> wrote:

> 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
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list