ent: Tuesday, 13 April 2010 1:34 p.m.
> To: r-help@r-project.org
> Subject: [R] efficiently picking one row from a data frame per unique
> key
>
> Hello all, I'm trying to transform data frames by grouping the rows by
> the
> values in a particular column, ordered by anot
James -
If I understand you correctly:
getone = function(df)df[order(df$x,df$y),][1,]
describes what you want from each data frame corresponding
to a unique value of x. Then, supposing that your data frame
is called df:
sdf = split(df,df$x)
will create a list of data frames for the uniqu
Hello all, I'm trying to transform data frames by grouping the rows by the
values in a particular column, ordered by another column, then picking the
first row in each group.
I'd like to convert a data frame like this:
x y z
1 10 20
1 11 19
2 12 18
4 13 17
into one with three rows, like this,
3 matches
Mail list logo