Description Usage Arguments Note Source Examples
View source: R/dt.count_dt.filter_dt.select.R
A function that counts the number of rows that meets the qualification such as filter and the by (grouping variables). If both filter and the grouping variables are not set up, then it will return the number of rows.
1 2 3 4 5 6 7 |
dat |
a data.frame object. |
the.filter |
a character value, logical value, or expression stating the logical operations to be performed in filtering the data prior to calculating the.function. Defaults to "NULL" unless specified. |
grouping.variables |
a character vector specifying variables to group by in performing the computation. Only values that exist in names(dat) will be used. |
grouping.type |
a character value specifying whether the grouping should be sorted (keyby) or as is (by). Defaults to keyby unless "by" is specified. |
count.name |
a character value specifying the name of the column of counts in the resulting table. Defaults to "N" unless specified. |
the data.frame dat will be converted to a data.table object to facilitate adding the new column by reference (e.g. efficiently with regard to the usage of memory)
DTwrappers::create.filter.expression
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | age.name = "Age"
income.name = "Income"
region.name = "Region"
gender.name = "Gender"
dt.count(dat = formulaic::snack.dat)
dt.count(dat = formulaic::snack.dat,
grouping.variables = c(region.name, gender.name))
dt.count(dat = formulaic::snack.dat,
the.filter = "Age > 65",
grouping.variables = c(region.name, gender.name),
count.name = "Records with Age > 65")
dt.count(dat = formulaic::snack.dat,
the.filter = 'get(age.name) > 20',
grouping.variables = c(age.name,income.name),
grouping.type = 'keyby', count.name = "counts")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.