[R] Nested loop R code

Ulrik Stervbo ulrik.stervbo at gmail.com
Fri Sep 8 12:20:17 CEST 2017


Hi Hemant,

please write to the r-help list in the future.

Look at the cut () function to solve your problem.

Also, you have a problem in your example - 5 is placed in two different
categories.

HTH
Ulrik

On Fri, 8 Sep 2017 at 12:16 Hemant Sain <hemantsain55 at gmail.com> wrote:

> i have a vector containing values ranging from 0 to 24
> i want to create another variable which can categorize those values  like
> this
> please help me with an R code
>
> Thanks
>
> *Value       New_Var*1            0 -5
> 3            0 -5
> 5            0 -5
> 9            6-10
> 7            6-10
> 5            6-10
> 4             0-5
> 11          11-15
> 12         11-15
> 18          16-20
> 23          21 -25
>
>
> --
> hemantsain.com
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list