Dear all, I have a data set in which the same unit appears 2 or 3 or 4 times. I need to aggregate this data to maintain only one unit by row. But I need to do that based on a comparison between the values of such units. I can't find a function to help me on that. I appreciate any help. Below I provide an example of what I want:
This is my data: Units Var1 Var2 Var3 1 B 2 2 1 C 1 3 2 D 3 3 2 C 2 1 2 A 1 2 3 C 2 1 3 A 1 3 4 B 3 3 4 C 2 2 4 A 1 1 I want to produce a new data in which I keep, for each unit, the row with max number for Var2. For instance, Units Var1 Var2 Var3 1 B 2 2 2 D 3 3 3 C 2 1 4 B 3 3 Thanks, *Felipe Nunes* CAPES/Fulbright Fellow PhD Student Political Science - UCLA Web: felipenunes.bol.ucla.edu [[alternative HTML version deleted]] ______________________________________________ R-help@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.