Displaying 1 result from an estimated 1 matches for "age_f".
Did you mean:
age_p
2009 Sep 22
1
cut and re-factor data
...gregates the age factors if the
existing factors have insufficient counts. Then I can use aggregate to
build a new data set.
I figured out I can get the cut values I want using cut2 from Hmisc
>count
[1] 10 20 20 50 50 50 50 50 50 50 50 50 50 50 10 20 20
>age_bucket <- seq (0,80,5)
>age_f <- factor(age_bucket)
> age_f
[1] 0 10 15 20 25 30 35 40 45 5 50 55 60 65 70 75 80
Levels: 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80
ct <- rep(age_bucket, count)
cut50 <- cut2(ct,m=50)
levels(cut50)
[1] "[ 0,15)" "15" "20" "25"...