Displaying 1 result from an estimated 1 matches for "agecatagory".
2009 Apr 24
3
Help with for/if loop
...ave 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 on...