Learn R Programming

BMSC (version 0.2.1)

prepDatForPredict: Exclude rows with missing data on predictor variables

Description

Rows with missing values on predictor variables are excluded. An unused column for the dependent variable is added to avoid errors.

Usage

prepDatForPredict(formula, newdata)

Arguments

formula

Model formula

newdata

data.frame containing all variables that appear in the model

Value

Object of class na.exclude

Details

A column of ones for the dependent variable is added. Otherwise model.matrix tries to take it from the formula's environment, which is the original data. This usually results in an error due to unequal variable length. This column is however not used.