[R] extract rows with unique values from data.frame

Nicolas Gutierrez nicolasg at uw.edu
Tue Mar 8 04:51:36 CET 2011


Hello!

I have the data frame "pop":

     xloc yloc  gonad  ind    Ene    W   Agent
1    23  20   516.74   1     0.02 20.21 0.25
2    23  20  1143.20   1     0.02 20.21 0.50
3    21  19   250.00   1     0.02 20.21 0.25
4    22  15   251.98   1     0.02 18.69 0.25
5    24  18   598.08   1     0.02 18.69 0.25

And I need to extract the number of rows that have unique (xloc, yloc) 
values. For example I need 2 unique cells (xloc,yloc) so the number of 
rows to extract would be 3 as follows:

     xloc yloc  gonad  ind    Ene    W   Agent
1    23  20   516.74   1     0.02 20.21 0.25
2    23  20  1143.20   1     0.02 20.21 0.50
3    21  19   250.00   1     0.02 20.21 0.25

Thanks for any help!

Nico



More information about the R-help mailing list