dt_count | R Documentation |
dt_count
calculates number of cases by groups, possibly
weighted. dt_add_count
adds number of cases to existing dataset.
dt_top_n
returns top n rows from each group.
dt_count(data, ..., weight = NULL, sort = FALSE, name = "n") dt_add_count(data, ..., weight = NULL, sort = FALSE, name = "n") dt_top_n(data, n, by, order_by = NULL)
data |
data.table/data.frame data.frame will be automatically converted to data.table. |
... |
variables to group by. |
weight |
optional. Unquoted variable name. If provided result will be the sum of this variable by groups. |
sort |
logical. If TRUE result will be sorted in desending order by resulting variable. |
name |
character. Name of resulting variable. |
n |
numeric. number of top cases. If n is negative then bottom values will be returned. |
by |
list or vector of grouping variables |
order_by |
unquoted variable name by which result will be sorted. If not specified, defaults to the last variable in the dataset. |
data.table
data(mtcars) # dt_count dt_count(mtcars, am, vs) dt_add_count(mtcars, am, vs, name = "am_vs")[] # [] for autoprinting # dt_top_n dt_top_n(mtcars, 2, by = list(am, vs)) dt_top_n(mtcars, 2, order_by = mpg, by = list(am, vs))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.