检查
?model.matrix
. 片断:
## Default S3 method:
model.matrix(object, data = environment(object),
contrasts.arg = NULL, xlev = NULL, ...)
Arguments:
object: an object of an appropriate class. For the default method, a
model formula or a âtermsâ object.
你的
object
是字符串公式,而
data
是
data_A
. 这个
对象
如前所述,参数应为公式或术语对象。尝试
model.matrix(Y ~ X1 + X2, data_A)
或等效(如果是从字符串构造公式)
model.matrix(as.formula(Y ~ X1 + X2), data_A)