RUsers,

I am trying (with little success) to determine how to combine unique and 
min to do some data frame manipulations and I could use a little advice. 
  I have tried various combinations of 'unique', 'min' and 'apply' with 
no luck.

Given this simple example data (x, y)

x<-c(10, 10, 12, 13, 15, 16 ,17, 17, 17)
y<-c(112, 117, 111, 117, 114, 113, 119, 121, 130)

as.data.frame(cbind(x, y))

    x   y
1 10 112
2 10 117
3 12 111
4 13 117
5 15 114
6 16 113
7 17 119
8 17 121
9 17 130

I have been attempting to get all those unique 'x-y' combinations for 
which the y column is the minimum of the values y takes for each unique 
x (ID variable), such as below.

    x   y
1 10 112
3 12 111
4 13 117
5 15 114
6 16 113
7 17 119

Any advice/directions I could look would be appreciated.

TIA,
Bret
R 2.6.0; platform i386-pc-mingw32

______________________________________________
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.

Reply via email to