Douglas Bates wrote: > As Henrique said, the canonical way of assigning a value within an > environment is the "assign". A more obscure, but also more effective, > approach is evalq which quotes an expression then evaluates it in the > given environment. For example > > >> env <- new.env() >> evalq({aa <- 1:3; bb <- LETTERS[1:9]; cc <- list(A = aa, B = bb)}, env) >> objects(env) >> > [1] "aa" "bb" "cc" > >> env$aa >> > [1] 1 2 3 >
Yes, and the with() construct works similarly. You do have to be careful to note that also the right hand side of the assignment is evaluated in env. This can have unexpected consequences. Notice also the possibility of lexical scoping and superassignment "<<-". See for instance file.show(system.file("demo/scoping.R", package="base")) -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ 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.