[R] filter data set unique, duplicate..

From: Anders Bjørgesæter <anders.bjorgesater_at_bio.uio.no>
Date: Wed 03 Aug 2005 - 18:40:23 EST


Hello

First, thanks for the help for an earlier question about error handling!

I have problem filtering a dataset.
I'm trying to filter the data in the y columns based on the values in the x column, e.g.:

x          y1        y2                    yn
1.0       1          NA                  3
2.0       1          NA                  11
2.0       2          NA                  NA
3.0       1          5                      16
3.0       7          5                      2
4.0       8          4                      1

and want to keep the highest y if x is identical, like this:

x          y1        y2                    yn
1.0       1          NA                  3
2.0       2          NA                  11
3.0       7          5                      16
4.0       8          4                      1

or just as good:

x          y1        y2                    yn
1.0	   1          NA                  3
2.0       NA*    NA                  NA
2.0       2          NA                  11
3.0       NA*    5                      16
3.0       7          NA*                NA*
4.0       8          4                      1

If any has any suggestions or pointers how to do this I would really appreciate it.

/Anders



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Aug 03 18:46:37 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:39 EST