Skip to content
Prev 85531 / 398506 Next

norm package prelim.norm

Others will certainly suggest more efficient ways to do this, but 
here is an inefficient approach:

 > X <- matrix(sample(c(0,1), 10000*3, replace=TRUE), ncol=3)
 > t(t(table(apply(X, 1, paste, collapse=""))))

       [,1]
   000 1197
   001 1238
   010 1245
   011 1230
   100 1331
   101 1259
   110 1247
   111 1253

   You are getting a warning and not an error from prelim.norm(), and 
the answer it gives seems to match the approach above.

 > library(norm)
 > X <- apply(X, 2, function(x){replace(x, x == 0, NA)})
 > prelim.norm(X)$r
      [,1] [,2] [,3]
1253    1    1    1
1230    0    1    1
1259    1    0    1
1238    0    0    1
1247    1    1    0
1245    0    1    0
1331    1    0    0
1197    0    0    0

hope this helps,

Chuck
Elizabeth Lawson wrote: