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

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

Examples

iris %>% topn_dt(Sepal.Length,10)
#> Error in topn_dt(., Sepal.Length, 10): could not find function "topn_dt"
iris %>% topn_dt(Sepal.Length,-10)
#> Error in topn_dt(., Sepal.Length, -10): could not find function "topn_dt"
iris %>% topfrac_dt(Sepal.Length,.1)
#> Error in topfrac_dt(., Sepal.Length, 0.1): could not find function "topfrac_dt"
iris %>% topfrac_dt(Sepal.Length,-.1)
#> Error in topfrac_dt(., Sepal.Length, -0.1): could not find function "topfrac_dt"