3

I'm trying to call felm() from the lfe package inside of a function in the following way:

require(lfe)
analysis_function <- function(dataset) { 
    formula_for_fn <- paste0(c(reformulate(
                               termlabels=c('a','b','c','d'),
                               response=e),
                             ' | a | 0 | a + b + c'), sep='',
                             collapse='')

    model <- do.call("felm", list(formula=formula_for_fn,
                                  data=dataset))
}

I am getting the following error:

Error in new.env(parent = formenv) : use of NULL environment is defunct

Can anyone help me figure out what is going wrong / how I can fix it? Thanks!

Michael Ohlrogge
  • 10,559
  • 5
  • 48
  • 76
araspion
  • 693
  • 1
  • 9
  • 24
  • 3
    You didn't provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so it's not super easy to help you but i'm guessing the function expects a formula and you are just passing in a string that looks like a formula. Try using `as.formula()` before using it in the `do.call` – MrFlick Aug 05 '16 at 03:19

0 Answers0