I have a set of data that includes various data columns. One if the survival time and another if a continuous variable of ages. I want to put the ages into intervals so that I can then perform the Kalpan Meier test. I am trying to use the following code to build a column with the age group numbers in
agecatagory<-c( ) for (i in 1:137) { { if(age[i]<=46) {agecat[i]<-1} if(age[i]>46 & age[i]<= 58) {agecat[i]<-2} if(age[i]>58) {agecat[i]<-3} } agecatagory<-c(agecatagory, agecat[i]) } I have been getting various errors for various things and have finally got it so that only one error comes up Error in if (age[i] <= 46) { : missing value where TRUE/FALSE needed Could anyone pleaseeeeeee shed some light on this for me and tell em where I am going wrong. I am sure it is just a minor thing but I cant for the life of me figure it out! Your replies will be very much appreciated! Hollie -- View this message in context: http://www.nabble.com/Help-with-for-if-loop-tp23207428p23207428.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list 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.