drop_pattern: Drop predictors

Description Usage Arguments Details Value See Also Examples

View source: R/drop_effects.R

Description

Drop predictor variables according to a (regex) pattern

Usage

1

Arguments

form

a formula object

pattern

predictors matching this pattern will be dropped

...

further arguments passed on to grepl

Details

form is divided into its individual terms, any term matching pattern is removed, before form is updated and returned. In case no match is made, form is returned unmodified. In case all predictors match, only the intercept is retained. In any case the response variable(s) are kept as is.

Value

A formula object

See Also

drop_randfx

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
f6 <- y ~ aa*bb + aa + ac + cc + acab

drop_pattern(f6, "a") # Drop all containing a
drop_pattern(f6, "a{2}") # Drop all containing exactly 2 consecutive as
drop_pattern(f6, "^[^a]*a[^a]*$")  # All containing exactly 1 a
drop_pattern(f6, ":") # Drop interaction
drop_pattern(f6, "^[^:]*a[^:]*$") # Drop all containg a, but not interaction
drop_pattern(f6, "^((?!a).)*$", perl=TRUE) # Drop all not containing a

# Degenerate cases
drop_pattern(f6, "[abc]") # Drop all
drop_pattern(f6, "q") # Drop none

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.