1

I want a vector of variable names from a formula and used the following code: and tried the second one as well.

rhs <- all.vars(update(formula, 0~.))
rhs <- all.vars(update(formula, 0~., evaluate = FALSE))

Every now and then I get the following warning, although it still executes correctly:

Warning messages:
1: Unknown column 'levels' 
2: Unknown column 'levels' 
3: Unknown column 'levels' 
4: Unknown column 'levels' 
5: Unknown column 'levels' 
6: Unknown column 'levels' 

What is going on? And why does this happen at random?

almcd
  • 1,069
  • 2
  • 16
  • 29
Roel Hogervorst
  • 299
  • 3
  • 13
  • 1
    I am not sure, but this possibly might be an error in the `dplyr`or rather `tibble` package. See http://stackoverflow.com/q/39041115/2114932 – dpprdan Aug 22 '16 at 12:21

1 Answers1

2

To get all variable names on the lhs or rhs of a formula you do this:

frm <- x  + y ~ sin(z)
lhs <- all.vars(frm[[2]])
rhs <- all.vars(frm[[3]])

A formula object is accessible as a list, the 1st element is the '~', the 2nd the lhs, the 3rd the rhs.