Guest User

Untitled

a guest
May 16th, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Combine multiple categorical variables in one dummy variable
  2. agegroup{<20,20-30,>03}
  3. disease.level{0,1,2},
  4. performance{<60, >=60}
  5.  
  6. > ff <- expand.grid(agegroup=factor(c("<20","20-30",">30")),
  7. disease.level=factor(0:2),performance=factor(c("<60",">=60")))
  8. > combfac <- with(ff,interaction(agegroup,disease.level,performance))
  9. > combfac
  10. [1] <20.0.<60 20-30.0.<60 >30.0.<60 <20.1.<60 20-30.1.<60
  11. [6] >30.1.<60 <20.2.<60 20-30.2.<60 >30.2.<60 <20.0.>=60
  12. [11] 20-30.0.>=60 >30.0.>=60 <20.1.>=60 20-30.1.>=60 >30.1.>=60
  13. [16] <20.2.>=60 20-30.2.>=60 >30.2.>=60
  14. 18 Levels: <20.0.<60 20-30.0.<60 >30.0.<60 <20.1.<60 20-30.1.<60 ... >30.2.>=60
Advertisement
Add Comment
Please, Sign In to add comment