[R] Count number of different patterns (Polytomous variable)

jim holtman jholtman at gmail.com
Tue Sep 8 19:29:22 CEST 2009


try this:

> x
  V1 V2 V3
1  0  3  1
2  1  2  0
3  1  2  0
> unique(x)
  V1 V2 V3
1  0  3  1
2  1  2  0
> nrow(unique(x))
[1] 2
>


2009/9/8 "Biedermann, Jürgen" <juergen.biedermann at charite.de>:
> Hi there,
>
> Does anyone know a method to calculate the number of different patterns in a
> given data frame. The variables are of polytomous type and not binary (for
> the latter i found a package called "countpattern" which unfortunately only
> functions for binary variables).
>
> V1   V2   V3
> 0   3   1
> 1   2   0
> 1   2   0
>
> So, in this case, i would like to get "2" as output.
>
> Thanks in advance
> Jürgen
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list