Skip to content
Prev 44814 / 398506 Next

be careful: using attach in R functions

Using attach() in this context may not be wise.  I tend to only use 
attach() when working interactively.  It might be better to use with() 
in this situation, such as

f <- function() {
	theta <- list(one=2.0, two=0.3, three=0.4)
	x <- with(theta, c(one, two, three))
	sample(x, 1)
}

-roger
li dongfeng wrote: