topn: Select top (or bottom) n rows (by value)

Description Usage Arguments Value See Also Examples

Description

Analogous function for top_n and top_frac in dplyr, but with a different API.

Usage

1
2
3
top_n_dt(data, n, wt)

top_frac_dt(data, n, wt)

Arguments

data

data.frame

n

If n is positive, selects the top rows. If negative, selects the bottom rows.

wt

The numeric variable to use for ordering.

Value

data.table

See Also

top_n,dt_top_n

Examples

1
2
3
4
iris %>% topn_dt(Sepal.Length,10)
iris %>% topn_dt(Sepal.Length,-10)
iris %>% topfrac_dt(Sepal.Length,.1)
iris %>% topfrac_dt(Sepal.Length,-.1)

hope-data-science/tidydt0 documentation built on Feb. 3, 2020, 12:04 a.m.