[R] how to simplify a data.frame and add the counts of duplicate rows as a new column

From: Simone Gabbriellini <simone.gabbriellini_at_gmail.com>
Date: Wed, 02 Mar 2011 16:10:20 +0100


Hello List,

I would like to simplify a data.frame like this

columnA	columnB
user10		proj12
user10		proj19
user10		proj12

into something like:

columnA	columnB	columnC
user10		proj12		2
user10		proj19		1

I know unique() can simplify the data.frame, but how to count and store the duplicates?

thanks in advance for any help.

best regards,
Simone



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. Received on Wed 02 Mar 2011 - 15:49:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Mar 2011 - 15:50:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive