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

anteneh asmare h@n@tezer@ @end|ng |rom gm@||@com
Tue Jun 14 19:47:26 CEST 2022


Hello Tim, Rui
Thank you very much for your time and unreserved support.
Best,
Hana

On 6/14/22, Rui Barradas <ruipbarradas using sapo.pt> wrote:
> Hello,
>
> Inline.
>
> Às 14:49 de 14/06/2022, Ebert,Timothy Aaron escreveu:
>> A problem in R is that there are several dozen ways to do any of these
>> basic activities. I used the approach that I could get to work the fastest
>> and tried to make it somewhat general. I do not know functions like
>> ?pretty that Rui used, nor ?quantile or ?cut. It is a difficulty in
>> learning R where the internet or sites like this one are the "teacher."
>
> Yes, that's unfortunately true.
>
> In this particular case I've learned about pretty() because I used to
> use hist(., plot=FALSE) to get pretty breakpoints. And hist's
> documentation says it uses pretty().
>
>
> There are plenty of books, but they too take one approach to solve a
> problem rather than "here is a problem" and "these are all possible
> solutions." I appreciate seeing alternative solutions.
>
> This thread is a good example of a "teacher" with several solutions,
> there are many more threads like this.
>
> Rui Barradas
>
>>
>> Tim
>>
>> -----Original Message-----
>> From: R-help <r-help-bounces using r-project.org> On Behalf Of Richard O'Keefe
>> Sent: Tuesday, June 14, 2022 9:08 AM
>> To: anteneh asmare <hanatezera using gmail.com>
>> Cc: R Project Help <r-help using r-project.org>
>> Subject: Re: [R] Create a categorical variable using the deciles of data
>>
>> [External Email]
>>
>> 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-9
>>> 0','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://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mail
>>> man_listinfo_r-2Dhelp&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAs
>>> Rzsn7AkP-g&m=JNEsCwSpVwVmoMiEXA8K7ZWqg1GZK3Cx87LshtZ5gy5Y8SyDZrUSTuotO
>>> cQ44yzy&s=2x4gMg5K_GJPK-XUk3UfSB3hhFCziCOgqvxl7yJXTvA&e=
>>> PLEASE do read the posting guide
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.or
>>> g_posting-2Dguide.html&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeA
>>> sRzsn7AkP-g&m=JNEsCwSpVwVmoMiEXA8K7ZWqg1GZK3Cx87LshtZ5gy5Y8SyDZrUSTuot
>>> OcQ44yzy&s=50k59quZy2KmFsVBRxK4P-M7RyxDsPGieX6TiiY5or0&e=
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>          [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=JNEsCwSpVwVmoMiEXA8K7ZWqg1GZK3Cx87LshtZ5gy5Y8SyDZrUSTuotOcQ44yzy&s=2x4gMg5K_GJPK-XUk3UfSB3hhFCziCOgqvxl7yJXTvA&e=
>> PLEASE do read the posting guide
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=JNEsCwSpVwVmoMiEXA8K7ZWqg1GZK3Cx87LshtZ5gy5Y8SyDZrUSTuotOcQ44yzy&s=50k59quZy2KmFsVBRxK4P-M7RyxDsPGieX6TiiY5or0&e=
>> and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> 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.
>



More information about the R-help mailing list