[R] [FORGED] Help with the Cut Function

Rolf Turner r.turner at auckland.ac.nz
Sat Jun 25 23:49:02 CEST 2016


On 26/06/16 07:05, Shivi Bhatia wrote:
> Dear Team,
>
> Please see the code below:
>
> Age1<- cut(desc$Age, breaks = c(20,30,40,Inf),labels = c("Low","Mid","Top"))
> here i am creating three categories as mentioned from the age var from desc
> data set.
> All the values are set correctly however the values which are below 20 are
> set to NA.
> Is there anything i am doing incorrect.

No.  What is the problem?  This seems to me to be exactly what one would 
expect.

If you don't want NAs, set your lower break to be less than the minimum 
of desc$Age, e.g. -Inf.

cheers,

Rolf Turner

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-help mailing list