[R] Help needed

Petr Pikal petr.pikal at precheza.cz
Wed Apr 26 09:13:53 CEST 2006


Hi

you experienced difference between matrix (cbind(....)) and data 
frame (data.frame(......)) or you have some NA value in your BMIGRP1

try:
maxcls<-max(dset[,2], na.rm=T)
if you have some NA values
or use
str(dset) to look what types are your variables.

HTH
Petr


On 25 Apr 2006 at 18:16, Anamika Chaudhuri wrote:

Date sent:      	Tue, 25 Apr 2006 18:16:42 -0700 (PDT)
From:           	Anamika Chaudhuri <canamika16 at yahoo.com>
To:             	"Richard M. Heiberger" <rmh at temple.edu>, r-help at stat.math.ethz.ch
Subject:        	Re: [R] Help needed

> As my earlier email said I am not getting the maxcls. I do get numbers
> coded as 1,2,3 for BMIGRP(when I print BMIGRP) but not getting the max
> of (1,2,3) which should be 3, I guess.
> 
>   Thanks for your help
>   Anamika
> 
> 
> Anamika Chaudhuri <canamika16 at yahoo.com> wrote:
>     > dset1<-cbind(AGE,BMI,DEATH)
> > BMIGRP<-cut(BMI,breaks=c(14,20,25,57),right=TRUE)
> > levels(BMIGRP)
> [1] "(14,20]" "(20,25]" "(25,57]"
> > BMIGRP1<-as.numeric(BMIGRP)
> > AGEGRP<-floor(AGE/10)-2
> > dset<-cbind(AGEGRP,BMIGRP1,DEATH)
> > maxage<-max(dset[,1])
> > minage<-min(dset[,1])
> > maxcls<-max(dset[,2])
> > maxcls
> [1] NA
> 
>   Why doesnt it give me a no for maxcls then?
> 
>   Thanks.
> 
> 
> "Richard M. Heiberger" <rmh at temple.edu> wrote:
>   > x <- rnorm(100)
> > xx <- cut(x,3)
> > levels(xx)
> [1] "(-2.37,-0.716]" "(-0.716,0.933]" "(0.933,2.58]" 
> > as.numeric(xx)
> 
> 
> ---------------------------------
> 
> 
> 
> ---------------------------------
> 
>  [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal at precheza.cz




More information about the R-help mailing list