Dear R users,

How do I drop multiplication terms from a formula using update?
e.g.
forml=as.formula("Surv(time, status) ~ x1+x2+A*x3+A*x4+B*x5+strata(sex)")

#I would like to drop all instances of variable A (the main effect and its 
interactions). The following:
updated.forml=update(forml, ~ . -A)

#gives me this:
#Surv(time, status) ~ x1 + x2 + x3 + x4 + B + x5 + strata(sex) + A:x3 + A:x4 + 
B:x5

#but I want this:
#updated.forml=as.formula("Surv(time, status) ~ x1+x2+x3+x4+B*x5+strata(sex)")

Any ideas?
Thanks in advance

Eleni Rapsomaniki

Research Associate
Strangeways Research Laboratory
Department of Public Health and Primary Care
University of Cambridge
 

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to