Description Usage Arguments Details Value Author(s) Examples
View source: R/filter_extreme.R
Filters the first or last observation for each by group.
1 | filter_extreme(dataset, by_vars = NULL, order, mode, check_type = "warning")
|
dataset |
Input dataset The variables specified by the |
by_vars |
Grouping variables Permitted Values: list of variables |
order |
Sort order Within each by group the observations are ordered by the specified order. Permitted Values: list of variables or functions of variables |
mode |
Selection mode (first or last) If Permitted Values: |
check_type |
Check uniqueness? If Default: Permitted Values: |
For each group (with respect to the variables specified for the
by_vars
parameter) the first or last observation (with respect to the
order specified for the order
parameter and the mode specified for the
mode
parameter) is included in the output dataset.
A dataset containing the first or last observation of each by group
Stefan Bundfuss
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(dplyr, warn.conflict = FALSE)
library(admiral.test)
data("ex")
# Select first dose for each patient
ex %>%
filter_extreme(
by_vars = vars(USUBJID),
order = vars(EXSEQ),
mode = "first"
) %>%
select(USUBJID, EXSEQ)
# Select highest dose for each patient
ex %>%
filter_extreme(
by_vars = vars(USUBJID),
order = vars(EXDOSE),
mode = "last",
check_type = "none"
) %>%
select(USUBJID, EXDOSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.