Select top n rows in each group, ordered by wt within a nested dataframe

top_n_nested(df, n = 2, wt)

Arguments

df

A nested dataframe

n

Number of rows to return

wt

The variable to use for ordering