I'm trying to find a good way of attaching a list within a function such 
that the attached variables (the list's members) precede the global 
environment (.GlobalEnv) in the search list.  Here is a non-working example 
using attach(), which hopefully explains better what I'm trying to do:

 > foo <- function(x=0, input=list(a=10)) {
+   attach(input)
+   on.exit(detach(input))
+   print(search())
+   print(a)
+ }
 >
 > a
Error: Object "a" not found
 > foo()  ## this prints out a = 10
[1] ".GlobalEnv"       "input"            "package:methods"  "package:stats"
[5] "package:graphics" "package:utils"    "Autoloads"        "package:base"
[1] 10
 >
 > a <- 0
 > foo()  ## this prints out a = 0, not a = 10
[1] ".GlobalEnv"       "input"            "package:methods"  "package:stats"
[5] "package:graphics" "package:utils"    "Autoloads"        "package:base"
[1] 0
 >


Thanks,

                 Gardar


___________________________________________________________________
Gardar Johannesson
Lawrence Livermore National Laboratory
7000 East Avenue, L-229
Livermore, CA 94550

johannesson1@llnl.gov
Tel: (925) 422-3901,  Fax: (925) 422-4141
	[[alternative HTML version deleted]]


