exclude_rows: Exclude rows of NONMEM dataset

Description Usage Arguments Value See Also Examples

View source: R/derived-data-prep.R

Description

[Stable]

A mechanism for excluding outliers during data cleaning. Create exploratory plots, identify rows of the dataset to be considered outliers for exclusion, and then feed that filtered dataset into this function to exclude them from the dataset. Requires a corresponding IGNORE statement - see argument descriptions for more details.

Usage

1
exclude_rows(d, dexcl, exclude_col = "EXCL")

Arguments

d

A data.frame for containing the full NONMEM dataset. Should contain a column for identifying excluded rows named with the exclude_col argument.

dexcl

A smaller data.frame consisting of rows to be ignored. Need not contain all columns of d but each column should be present in d.

exclude_col

Character (default = "EXCL"). Name of a binary exclude column in d. This should be accompanied with a IGNORE=(EXCL.GT.0) statement in $DATA.

Value

A modified version of d with exclude_col set to 1 for rows coinciding with dexcl.

See Also

read_derived_data(), write_derived_data()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# create example object m1 from package demo files
exdir <- system.file("extdata", "examples", "theopp", package = "NMproject")
m1 <- new_nm(run_id = "m1", 
             based_on = file.path(exdir, "Models", "ADVAN2.mod"),
             data_path = file.path(exdir, "SourceData", "THEOPP.csv"))
             
d <- input_data(m1)
d$EXCL <- 0  ## start with no rows excluded

## use with dplyr
dexcl <- d %>%
  dplyr::filter(ID == 6, TIME > 3) %>%
  dplyr::select(ID, TIME, DV, EXCL)
dexcl ## view rows to be excluded
d <- d %>% exclude_rows(dexcl)

d %>% dplyr::filter(ID %in% 6)

NMproject documentation built on Oct. 18, 2021, 1:08 a.m.