[R-sig-QA] [Fwd: create groups based upon different levels of 4 factors] update 1
Mary A. Marion
mmstat at comcast.net
Fri Nov 28 19:06:22 CET 2008
Hello to the R gurus,
My data is bound in a dataframe.
data2<-cbind.data.frame(digrp,gender, agegrp, bmigrp,wt)
data2[1:5,]
I want to create groups based upon different levels of 4 factors
ind<- as.logical ( (digrp=1) & (gender=1) & (agegrp="[20-35)") &
(bmigrp="[0,18.5)" ) );
Error in (digrp = 1) & (gender = 1) & (agegrp = "[20-35)") :
operations are possible only for numeric or logical types
>
I keep getting an error message. How do I see that the above statement
is in correct type format?
#operations are possible only for numeric or logical types. why does
it not include bmigrp?
Data was created as follows:
#BMI CLASSIFICATION
breaks<-c(0,18.5,25,30,200)
bmigrp<-cut(bmi,breaks=breaks,right=FALSE)
#AGE GROUPS
breaks<-c(1,35,60,90)
agegrp<-cut(age,breaks=breaks,right=FALSE)
#DI GROUPS
#1=yes has diabetes, 2=no does not have
digrp<-as.factor(join5[,"DIQ010"])
#GENDER GROUPS
#1=male, 2=female
gender<-as.factor(join5[,"RIAGENDR"])
#FORM DATA FRAME TO ANALYZE
data2<-cbind.data.frame(digrp,gender, agegrp, bmigrp,wt)
data2[1:5,]
Thanks.
Sincerely,
Mary A. Marion
More information about the R-sig-QA
mailing list