Dear all,

I want to use the deltavar() function from emdbook. I can use it directly from the command terminal but within a function it behaves weird.

Working example:
----------------------
library("emdbook")

fn <- function()
{
browser()
y <- 2
print(deltavar(y*b2, meanval=c(b2=3), Sigma=1) )
}

x <- 2
print(deltavar(x*b1, meanval=c(b1=3), Sigma=1) )
y<-3

fn()
------------------------

running this returns 4 for the first function call, which is fine.

For the call of deltavar in fn(), I get 9, i.e. the function uses y<-3 instead of the local y<-2. If y<- is commented, deltavar returns an error.

So why is the function not using the local variable and how do I make it use it?

Many thanks

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to