Re: [R] how can I attach a variable stored in

2007-09-21 Thread john seers (IFR)
"foo" )) ) # works #attach( foo.bar ) # works } Regards JS -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Waltman Sent: 20 September 2007 20:24 To: Leeds, Mark (IED) Cc: r-help@r-project.org Subject: Re: [R] how can I attach a va

Re: [R] how can I attach a variable stored in

2007-09-20 Thread Tony Plate
Here's a function that does what I think you want to do: > attach.firstvar <- function(file) { + tmpenv <- new.env() + vars <- load(file, envir=tmpenv) + x <- get(vars[1], envir=tmpenv, inherits=FALSE) + if (is.list(x)) + attach(x, name=vars[1]) + return(vars) + } > x

Re: [R] how can I attach a variable stored in

2007-09-20 Thread jim holtman
try: attach(get(ls(pat="^foo"))) On 9/20/07, Peter Waltman <[EMAIL PROTECTED]> wrote: > Hi Mark - > > Thanks for the reply. Sorry I didn't really clarify too well what I'm > trying to do. The issue is not that I can't see the variable that gets > loaded. > > The issue is that the variable is a

Re: [R] how can I attach a variable stored in

2007-09-20 Thread Peter Waltman
Hi Mark - Thanks for the reply. Sorry I didn't really clarify too well what I'm trying to do. The issue is not that I can't see the variable that gets loaded. The issue is that the variable is a list variable, and I'd like to write a function that will take the .RData filename and attach th

Re: [R] how can I attach a variable stored in

2007-09-20 Thread Leeds, Mark (IED)
I don't think I understand your question but John Fox has written a very nice documentat about scoping and environments on his website. It's probably easy to find the site by googling "John Fox" but, if you can't find it, let me know. As I said, I don't think that I understand your question but,