search for: timeu

Displaying 1 result from an estimated 1 matches for "timeu".

Did you mean: time
2004 Feb 24
6
be careful: using attach in R functions
...time usage. Adding a ``detach()'' call at the end of ``f'' will get rid of this problem. ############################### f <- function(){ theta <- list(one=2.0, two=0.3, three=0.4) attach(theta) x <- c(one, two, three) sample(x, 1) } test <- function(n=400){ timeu <- numeric(n) for(i in seq(n)){ timeu[i] <- system.time({ resi <- f() })[3] } plot(timeu) } test() ############################## ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Li Dongfeng ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ldf-nospacm at math.pku.edu.cn ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2004-02-24