Calculate data summary statistics for a `pk` object
# S3 method for pk
data_summary(obj, newdata = NULL, summary_group = NULL, ...)
A `data.frame` with variables including all the grouping variables in `summary_group`, `group_id`; `param_name` (the name of the summary statistic; see Details); `param_value` (the summary statistic value); `param_units` (the units of the summary statistic, derived from the units of the data).
A [pk()] model object. Must be fitted, or the function will exit with an error.
Optional: A `data.frame` containing new data for which to compute the TK stats. Must contain at least variables `Chemical`, `Species`, `Route`, `Dose`, `Conc`, `Dose.Units`, `Conc.Units`, either `Time_trans.Units` or `Time.Units`, and any other variables named in `tk_grouping`. Default `NULL`, to use the data in `get_data(obj)`.
A list of variables provided using a `dplyr::vars()` call. The data (either `newdata` or `obj$data`) will be grouped according to the unique combinations of these variables. For each unique combination of these variables in the data, a set of summary statistics will be computed. The default is `NULL`, to use the same data grouping that was set in [stat_nca()] for the `pk` object. However, you may specify a different data grouping if you wish.
Additional arguments. Not in use.
Caroline Ring
Get summary statistics for data in a `pk` object (or optionally, new data), using data groupings defined by `get_nca_group()` for the `pk` object (or optionally, new groupings). If you provide both `newdata` and `summary_group`, then everything in the `pk` object will be ignored and you will simply be doing data summary *de novo* (which may be what you want).
Summary statistics include, for each group:
- `n_obs`: the number of observations - `n_exclude`: The number of excluded observations - `n_detect`: The number of non-excluded detected observations - `n_series_id`: The number of unique series IDs - `n_timepts`: The number of unique time points - `n_ref`: The number of unique reference IDs - `tlast`: The time of the latest non-excluded observation - `tlast_detect`: The time of the latest non-excluded detected observation - `tfirst`: The time of the earliest non-excluded observation - `tfirst_detect`: The time of the earliest non-excluded detected observation