powered by
Analogous function for top_n and top_frac in dplyr, but with a different API.
top_n
top_frac
top_n_dt(data, n, wt = NULL)top_frac_dt(data, n, wt = NULL)
top_frac_dt(data, n, wt = NULL)
data.frame
If n is positive, selects the top rows. If negative, selects the bottom rows.
n
(Optional). The variable to use for ordering. If not specified, defaults to the last variable in the data.frame.
data.table
# NOT RUN { iris %>% top_n_dt(10,Sepal.Length) iris %>% top_n_dt(-10,Sepal.Length) iris %>% top_frac_dt(.1,Sepal.Length) iris %>% top_frac_dt(-.1,Sepal.Length) # }
Run the code above in your browser using DataLab