Skip to content

Environment issue when nesting irf(VAR()) inside function #17

@nicolaiberk

Description

@nicolaiberk

Hi,

thanks for providing this great package!

I am trying to call irf(VAR) from inside a function with dynamic argument(s):

f1 <- function(max_lag = 6){
  
  vars::irf(vars::VAR(EuStockMarkets, lag.max = get("max_lag", env = parent.frame())))
  
}

f1(max_lag = 12)

This results in

Error in get("max_lag", env = parent.frame()) : 
  object 'max_lag' not found

I presume the issue has something to do with the definition of the environments in irf() or VAR(). I played around with the env argument but to little avail. Maybe this is helpful?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions