Counting the number of unique case for each event

faers_counts(.object, ...)

# S4 method for class 'FAERSascii'
faers_counts(
  .object,
  .events = "soc_name",
  .fn = NULL,
  ...,
  .field = "reac",
  .na.rm = FALSE
)

Arguments

.object

A FAERSascii object.

...

Other arguments passed to specific methods, for FAERSascii method, other arguments passed to .fn().

.events

A character specify the events column(s) in the .field data to count the unique primaryid. If multiple columns were selected, the combination for all columns will define the interested events.

.fn

A function or formula defined the preprocessing function before creating contingency table, with the .field data as the input and return a data.table.

Note: When using the set* or := function from data.table with the "demo", "drug", "ther", "rpsr", and "outc" data, exercise caution as these functions directly modify the internal data. In such cases, it is advisable to use the copy function first.

If a function, it is used as is.

If a formula, e.g. ~ .x + 2, it is converted to a function with up to two arguments: .x (single argument) or .x and .y (two arguments). The . placeholder can be used instead of .x. This allows you to create very compact anonymous functions (lambdas) with up to two inputs.

If a string, the function is looked up in globalenv().

.field

A string indicates the interested FAERS fields to use. Only values "demo", "drug", "indi", "ther", "reac", "rpsr", and "outc" can be used.

.na.rm

A bool, whether NA value in .events column(s) should be removed.

Value

A data.table object.

Examples

# you must change `dir`, as the files included in the package are sampled
data <- faers(c(2004, 2017), c("q1", "q2"),
    dir = system.file("extdata", package = "faers"),
    compress_dir = tempdir()
)
#> Finding 2 files already downloaded: aers_ascii_2004q1.zip and
#> faers_ascii_2017q2.zip
#> → Combining all 2 <FAERS> Datas
if (FALSE) { # \dontrun{
# you must standardize and deduplication before disproportionality analysis
# you should replace `meddra_path` with yours
data <- faers_standardize(data, meddra_path)
data <- faers_dedup(data)
faers_counts(data)
} # }
std_data <- readRDS(system.file("extdata", "standardized_data.rds",
    package = "faers"
))
faers_counts(std_data)
#> Key: <soc_name>
#>                                                                soc_name     N
#>                                                                  <char> <int>
#>  1:                                Blood and lymphatic system disorders    11
#>  2:                                                   Cardiac disorders    16
#>  3:                          Congenital, familial and genetic disorders     1
#>  4:                                         Ear and labyrinth disorders     1
#>  5:                                                 Endocrine disorders     1
#>  6:                                                       Eye disorders     3
#>  7:                                          Gastrointestinal disorders    34
#>  8:                General disorders and administration site conditions    66
#>  9:                                             Hepatobiliary disorders     7
#> 10:                                             Immune system disorders     6
#> 11:                                         Infections and infestations    21
#> 12:                      Injury, poisoning and procedural complications    32
#> 13:                                                      Investigations    28
#> 14:                                  Metabolism and nutrition disorders    18
#> 15:                     Musculoskeletal and connective tissue disorders    18
#> 16: Neoplasms benign, malignant and unspecified (incl cysts and polyps)    12
#> 17:                                            Nervous system disorders    41
#> 18:                      Pregnancy, puerperium and perinatal conditions     3
#> 19:                                                      Product issues     4
#> 20:                                               Psychiatric disorders    24
#> 21:                                         Renal and urinary disorders    12
#> 22:                            Reproductive system and breast disorders     8
#> 23:                     Respiratory, thoracic and mediastinal disorders    24
#> 24:                              Skin and subcutaneous tissue disorders    25
#> 25:                                                Social circumstances     5
#> 26:                                     Surgical and medical procedures     8
#> 27:                                                  Vascular disorders    18
#>                                                                soc_name     N