multi_dims_stats_dt: Get multi-dimensions' stats using data.table

Description Usage Arguments Value Examples

View source: R/calc_multi_dims_stats.R

Description

rewrite 'multi_dims_stats()' using data.table to speed up the calculation. The usage of this function is the same as 'multi_dims_stats()' but the efficiency is at least 6 times higher.

Usage

1
2
3
4
5
6
7
multi_dims_stats_dt(
  data,
  ...,
  drug_colname = "drug",
  st_drug_name,
  ed_drug_name
)

Arguments

data

a **data table** with dimensions labels and drug monitoring data divided by MRL.

...

dimension names parameters. **NOT Character**. The supported dimensions are depending on 'data'. As for now, only 6 dimensions are supported:

* year * quarter * province * category * product * drug (depending on param 'drug_colname')

If you want to use (and you must use) this param, you should replace '...' with e.g. 'quarter, province, drug'.

drug_colname

the name of column containing drug names, and is the dimension name.

st_drug_name

the name of the first drug residual column.

ed_drug_name

the name of the last drug residual column. *Notice*: the column between 'st_drug_name' and 'ed_drug_name' should all be drug residual column.

Value

a data frame containing essential stats.

Examples

1
2
3
4
5
## without `drug`
# multi_dims_stats_dt(treated_data, year, province)
# multi_dims_stats_dt(treated_data)
## with `drug`
# multi_dims_stats_dt(treated_data, quarter, drug)

YuanchenZhu2020/antgreens documentation built on Dec. 18, 2021, 8:20 p.m.