Hi Neha,
I think you're looking for the "cut" function.
Jim
On Fri, Mar 4, 2022 at 8:10 AM Neha gupta <neha.bologna90 at gmail.com>
wrote:>
> Hello everyone
>
> I have a variable with about 5000 different values
>
> var1= c(0, 123, 400, .....4988)
>
> I want to convert it into different levels for some comparisons like
>
> if value is between 1-100 do something
> else
> do other things
>
> Is there any sophisticated way to do that than the following:
>
> var2=cut(var1, br=c(-1,500, 501,1000, 1001,5000))
>
> Thank you
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.