[R] norm package prelim.norm
Chuck Cleland
ccleland at optonline.net
Wed Feb 1 16:11:23 CET 2006
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:
> Hey eveyone! I hope someone can help wiht this question. I have a matirux of all zeros and ones and I would like to indentify all unique patterns in the rows andthe number of times the pattern occurs. I changed all zeros to NA tried to use prelim.norm to identify all patterns of missing data in the rows. I got the message
>
> Warning message:
> NAs introduced by coercion
>
> Any ideas of how to get this to work? Or are there any way to indentify all the unique patterns in a huge matrix? ( 10000 x 71)
>
> Thanks for any suggestions!!
>
> Elizabeth Lawson
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list