我正在诊断一个功能,最后发现错误来自这件作品,如:
# Function
miss<-function(formula, data, method="glm", family="binomial"){
if (method=="glm"){
fit1<-glm(formula,data=data,family=family)
xmatrix<-model.matrix(fit1,na.action=na.pass)
coef<-coef(fit1)
vcov<-vcov(fit1)
}
return(fit1)
}
# test data
set.seed(2014)
df<-data.frame(
group=rbinom(100,1,0.6),
sex=rbinom(100,1,0.3),
y=rbinom(100,1,0.8))
miss(y~group+sex,data=df, method="glm",family="binomial")
Error in data.frame(bv_aer_f7r = list(sid = c(1016L, 1022L, 1031L, 1036L, :
arguments imply differing number of rows: 96 ....
有人有想法我的功能有什么不对吗?