
Untitled
By: a guest on
May 16th, 2012 | syntax:
None | size: 0.67 KB | hits: 9 | expires: Never
Combine multiple categorical variables in one dummy variable
agegroup{<20,20-30,>03}
disease.level{0,1,2},
performance{<60, >=60}
> ff <- expand.grid(agegroup=factor(c("<20","20-30",">30")),
disease.level=factor(0:2),performance=factor(c("<60",">=60")))
> combfac <- with(ff,interaction(agegroup,disease.level,performance))
> combfac
[1] <20.0.<60 20-30.0.<60 >30.0.<60 <20.1.<60 20-30.1.<60
[6] >30.1.<60 <20.2.<60 20-30.2.<60 >30.2.<60 <20.0.>=60
[11] 20-30.0.>=60 >30.0.>=60 <20.1.>=60 20-30.1.>=60 >30.1.>=60
[16] <20.2.>=60 20-30.2.>=60 >30.2.>=60
18 Levels: <20.0.<60 20-30.0.<60 >30.0.<60 <20.1.<60 20-30.1.<60 ... >30.2.>=60