Skip to content
Prev 74829 / 398502 Next

filter data set unique, duplicate..

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