[R] A new environment within the main function

billy am wickedpuppy at gmail.com
Sun Sep 21 15:06:45 CEST 2014


Hi Everyone ,

I am having an issue with the following code and would need kind assistant.

For a specific reason , I would need to create a new environment for
variables within the function and use them and I am having issue with it on
the project I am doing.

The issue is that no matter what I do , I am getting the following error on

"Error in eval(expr, envir, enclos) : object 'x3' not found"

and it is the x3 that is within the groupedData(y~-1 + x3 | g

and not in the data.frame

fun1 <- function()
{
  ee <- new.env()
  t <- 10
  x <- 5
  g<- 8

  assign("x2",x,envir = as.environment(ee))

  x3 <- get("x2" , envir = as.environment(ee))

  if(t == 10)
  {
    if(g == 8)
      {

         data.fr <- groupedData(y~-1 + x3 | g,
                    data=data.frame(y,x3,h, dummy))
    }

  }

}

Thanks and Regards
Billy

	[[alternative HTML version deleted]]



More information about the R-help mailing list