Daniel Almirall wrote:
R-list,
1. Given a formula (f) w variables referencing some data set (dat), is
there any easier/faster way than this to get the names (in character form)
of the variables on the RHS of '~' ?
dat - data.frame(x1 = x1 - rnorm(100,0,1), x2 = x2 - rnorm(100,0,1), y = x1
+ x2
maybe something like:
f - y ~ x1 + x2
attr(terms(f), term.labels)
but this wan't work if you have a more complex formula (e.g., f - y ~
x1*x2 + I(x1^2)) and you want only c(x1, x2).
I hope it helps.
Best,
Dimitris
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public