search for: su4

Displaying 2 results from an estimated 2 matches for "su4".

Did you mean: s64
2017 Sep 02
0
Strange lazy evaluation of default arguments
...ng why u is not being copied to L just before u is assigned a new value. Of course, this would require the R interpreter to track all these dependencies in both ways incl. more complicated ones in which L might depend on more than just u. In the future, I?ll avoid dependencies between parameters. Su4 <- function(u=100, l=100, mu=0.53, sigma2=4.3^2) # instead of l=u And maybe also ?in-place? changes of values? Best regards, Matthias Von: William Dunlap Gesendet: Samstag, 2. September 2017 19:41 An: Rui Barradas Cc: Matthias Gondan; r-help at r-project.org Betreff: Re: [R] Strange lazy eva...
2017 Sep 02
2
Strange lazy evaluation of default arguments
Another way to avoid the problem is to not redefine variables that are arguments. E.g., > Su3 <- function(u=100, l=u, mu=0.53, sigma2=4.3^2, verbose) { if (verbose) { print(c(u, l, mu)) } uNormalized <- u/sqrt(sigma2) lNormalized <- l/sqrt(sigma2) muNormalized <- mu/sqrt(sigma2) c(uNormalized, lNormalized, muNormalized) } > Su3(verbose=TRUE)