这会给你新的formul对象。它们是否正常工作可能仍然存在问题,因为它们具有关联的环境,并且您没有提供用于测试的数据集。与兴田update.formula页面上的例子开始:
> ## Annette Dobson (1990) "An Introduction to Generalized Linear Models".
> ## Page 9: Plant Weight Data.
> ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
> trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
> group <- gl(2, 10, 20, labels = c("Ctl", "Trt"))
> weight <- c(ctl, trt)
> lm.D9 <- lm(weight ~ group)
> update.formula(lm.D9$call[[2]], .~.)
weight ~ group # Just to make sure that we got something sensible.
<environment: 0x1212230b0>
> update.formula(lm.D9$call[[2]], Z~.)
Z ~ group
<environment: 0x102799fc8>
似乎使用的weight
随机排列在我的测试情况下工作:
> Z <- sample(weight)
> lm(update.formula(lm.D9$call[[2]], Z~.), data.frame(Z=Z, group=group))
Call:
lm(formula = update.formula(lm.D9$call[[2]], Z ~ .), data = data.frame(Z = Z,
group = group))
Coefficients:
(Intercept) groupTrt
4.711 0.271
尝试使用'update'? – liuminzhao 2013-02-25 18:05:19
看起来很有用,乍一看。 – tomka 2013-02-25 18:15:28
在这种情况下,听起来好像你还没有完全描述你的问题,这很难回答。尝试更具体。运行一个特定的例子,用每一步中使用的实际代码。 – joran 2013-02-25 18:54:01