Skip to content

Commit 23155bd

Browse files
committed
Better handling of subset= in mlearning()
1 parent 129806e commit 23155bd

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

R/mlearning.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,15 @@
123123
mlearning <- function(formula, data, method, model.args, call = match.call(),
124124
..., subset, na.action = na.fail) {
125125
# Our own construction of response vector and terms matrix
126-
if (missing(model.args))
127-
model.args <- list(formula = formula, data = substitute(data),
128-
subset = substitute(subset))
126+
if (missing(model.args)) {
127+
if (missing(subset) || is.null(subset) || !length(subset) ||
128+
as.character(subset) == "") {
129+
model.args <- list(formula = formula, data = substitute(data))
130+
} else {
131+
model.args <- list(formula = formula, data = substitute(data),
132+
subset = substitute(subset))
133+
}
134+
}
129135

130136
# Get data and initial number of cases
131137
if (missing(data)) {

0 commit comments

Comments
 (0)