Hi,
   
  This one is not working for me. It is listing all the rows instead of unique 
ones. My dataset has 300000 odd rows and following is the resulting o/p
  
[[308313]]
[1] 126
  [[308314]]
[1] 126
  [[308315]]
[1] 126
  [[308316]]
[1] 126
  [[308317]]
[1] 126
  [[308318]]
[1] 126
  [[308319]]
[1] 126
  [[308320]]
[1] 126
  [[308321]]
[1] 126
   
  I used following set of commands.
   
  > (x.unique <- lapply(x$V1, unique))
> sapply(x.unique, length)
   
  x$V1 is numeric field.
  where x is my data frame already read (therefore i ignored your first step). 
Am I missing something. ?
   
  Thanks
  Sachin

"Liaw, Andy" <[EMAIL PROTECTED]> wrote:
  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]]
> 
> ______________________________________________
> [email protected] mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 


------------------------------------------------------------------------------

------------------------------------------------------------------------------


                
---------------------------------

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to