multi_dims_stats: Get multi-dimensions stats

Description Usage Arguments Value Examples

View source: R/calc_multi_dims_stats.R

Description

'multi_dims_stats()' creates a new data frame. It will have one or more rows for each combination of grouping dimensions. If there are no grouping dimensions, the output will have a single row summarising all samples in the input data frame. Despite the dimensions columns, it will contain other 3 or 6 columns depending on whether there is *drug* dimension in the dimension combination.

If *drug* dimension is in the dimension combination, it will report:

* 'sample_size': is the size of the sample set under specified dimensions. * 'detection_rate': is the detection rate of this specified sample set. * 'qualification_rate': is the qualification rate of this specified sample set.

If *drug* dimension is **not** in the dimension combination, it will report:

* 'sample_size': is the size of the sample set under specified dimensions. * 'qualification_rate': is the qualification rate of this specified sample set. * 'multi_detection_rate': is the multi-residue detection rate of this specified sample set. * 'max_defective_num': is the max multi-residue detection number of this specified sample set. * 'multi_defective_rate': is the multi-residue defective rate of this specified sample set. * 'max_defective_num': is the multi-residue defective number of this specified sample set.

Usage

1
multi_dims_stats(data, ..., drug_colname = "drug", st_drug_name, ed_drug_name)

Arguments

data

a data frame 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(treated_data, year, province)
# multi_dims_stats(treated_data)
## with `drug`
# multi_dims_stats(treated_data, quarter, drug)

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