[R] Count Unique Rows/Values
Liaw, Andy
andy_liaw at merck.com
Thu Apr 20 17:10:51 CEST 2006
This might help:
> x <- read.table("clipboard", colClasses=c("numeric", "character"))
> (x.unique <- lapply(x, unique))
$V1
[1] 155 138 126 123 103 143 111 156
$V2
[1] "A" "B" "C" "D"
> sapply(x.unique, length)
V1 V2
8 4
Andy
From: Sachin J
>
> Hi,
>
> I have a dataset which has both numeric and character
> values with dupllicates. For example:
>
> 155 A
> 138 A
> 138 B
> 126 C
> 126 D
> 123 A
> 103 A
> 103 B
> 143 D
> 111 C
> 111 D
> 156 C
>
> How can I count the number of unqiue entries without
> counting duplicate entries. Also can I extract the list in a
> object. What I mean is
> Col1 unique count = 8 Unique Elements are :
> 103,111,123,126,138,143,155,156
> Col2 unique count = 4 Unique Elements are : A,B,C,D.
>
> Any pointers would be of great help.
>
> TIA
> Sachin
>
>
>
> ---------------------------------
>
> [[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
>
>
More information about the R-help
mailing list