Hi David,

I tried as suggested however with this code:
Age11<- cut(desc$Age, breaks = c(-Inf, 20,30,40,Inf),labels =
c("Low","Mid","Top")) i receive an error message as below:

lengths of 'breaks' and 'labels' differ. Now as a result i have values
exceeding 40 as N/A.

On Sun, Jun 26, 2016 at 3:25 AM, David Winsemius <dwinsem...@comcast.net>
wrote:

>
> > On Jun 25, 2016, at 12:05 PM, Shivi Bhatia <shivipm...@gmail.com> wrote:
> >
> > Dear Team,
> >
> > Please see the code below:
> >
> > Age1<- cut(desc$Age, breaks = c(20,30,40,Inf),labels =
> c("Low","Mid","Top"))
>
> Try instead:
>
> Age1<- cut(desc$Age, breaks = c(-Inf, 20,30,40,Inf),labels =
> c("Low","Mid","Top"))
>
> Do note that values that are <= 20 will be in the lowest category. (You
> wrote only <20 whereas values of 20 would have not been in any interval.)
> The cut function also has a use.lowest argument, whose actions I don't
> fully understand but I usually set to to TRUE whereas is default is FALSE.
> I prefer the Hmisc::cut2 functions because its defaults mirror my usual
> interests. Like cut2, the findInterval function has closed intervals on the
> left.
>
> > 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.
> >
> > Regards, Shivi
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help@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.
>
> David Winsemius
> Alameda, CA, USA
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to