[R] Count number of different patterns (Polytomous variable)
Dimitris Rizopoulos
d.rizopoulos at erasmusmc.nl
Tue Sep 8 19:28:24 CEST 2009
try this:
DF <- data.frame(V1 = c(0,1,1), V2 = c(3,2,2), V2 = c(1,0,0))
DF
nrow(unique(DF))
I hope it helps.
Best,
Dimitris
Biedermann, Jürgen wrote:
> 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.
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
More information about the R-help
mailing list