Skip to content
Prev 274774 / 398506 Next

cut data into sevral group and assign calculated values individually

Thanks for your reply.

Let me make an example then:

m<- c(150, 400, 500,750,800, NA)

How can I use cut to generate the m_group as c(0,0.4755,1, 0.2275,0,0):

Breaks                  331.04      476.07      608.66       791.5                    NA
m_group        0                 x          1           x               0              0

Thank you very much!

Regards,
Yan

-----Original Message-----
From: Uwe Ligges [mailto:ligges at statistik.tu-dortmund.de] 
Sent: Tuesday, October 18, 2011 5:23 AM
To: Li, Yan
Cc: r-help at r-project.org
Subject: Re: [R] cut data into sevral group and assign calculated values individually
On 17.10.2011 20:53, Li, Yan wrote:
Based on the levels of the factor resulted by cut(), you can calculate a 
new vector easily. But since you have not specified a reproducible 
example, I cannot quickly change it in order to show how it works.

Best,
Uwe Ligges