ac0=c("WEIGHT","PREMENO","SMOKE") #this is the vector with names
ac1=glm(FRACTURE~PRIORFRAC+AGE+HEIGHT+MOMFRAC+RATERISK, data=glow, family='binomial')
ac2=update(ac1, formula.=~.+ac0[1])
错误是这样的:
Error in model.frame.default(formula = FRACTURE ~ PRIORFRAC + AGE + HEIGHT + :
invalid type (list) for variable 'ac0[1]'
答案 0 :(得分:2)
您可以创建公式,然后将其传递给更新:
mF <- formula(paste(". ~ . +", ac0[1]))
update(ac1, mF)