[R] repeating the same variable in formula

Subirana Cachinero, Isaac i@ubir@n@ @ending from imim@e@
Mon Dec 10 07:49:00 CET 2018


I am using terms.formula function to substract the variables from a formula environment.

Concretely, with the attr(*, "term.labels") I get the right side terms specified in the formula.

However, when introducing the same variable two or more times, this appears only once.

For example, when typing



>f <- y ~ cholesterol + age + age

>attr(terms(f),"term.labels")



I get



[1] "cholesterol" "age"



and I would like to get



[1] "cholesterol" "age" "age"





Is it possible with terms.formula function to obtain the variables and the times that they are specified in the formula? Or may I use another function?



Thanks in advance.



Isaac.


	[[alternative HTML version deleted]]



More information about the R-help mailing list