[R] dataset index

Lisa lisajca at gmail.com
Thu Dec 3 23:07:40 CET 2009


Hello, All,

I have a dataset that looks like this: 
  
x <- matrix(c(
0, 0, 0,
0, 0, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
1, 2, 1,
1, 2, 1,
1, 3, 1,
1, 3, 1,
1, 3, 1),
ncol = 5, byrow = T, 
dimnames = list(1:10, c("gender", "race", "disease")))

I want to write a function to produce several matrices including only “TRUE”
and “FALSE” for the different levels of the variables (these matrices may be
thought as index matrices), like

> m1
TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

> m2
FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE

> m3
FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE

> m4
FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE

Can anyone please help how to get this done? Your help would be greatly
appreciated. 

Lisa 

-- 
View this message in context: http://n4.nabble.com/dataset-index-tp948049p948049.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list