[18831] in s-news-athena
[S] Passing object names to attach, detach
daemon@ATHENA.MIT.EDU (Michael Prager)
Tue Aug 3 13:38:15 1999
Message-Id: <4.2.0.58.19990803131946.00a34e60@mail.bea.nmfs.gov>
Date: Tue, 03 Aug 1999 13:32:51 -0400
To: s-news@wubios.wustl.edu
From: Michael Prager <Mike.Prager@noaa.gov>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"; format=flowed
Is it possible to pass data frame names through function calls to
"attach()" and "detach()"? How?
The following simple example does not work:
hookup <- function(x)
{attach(x)}
hookup(test2.a)
In this case, a nonexistent directory "x" seems to get attached, rather
than the data frame passed by name. If there IS some approach that works
with "attach()", would the same approach work with "detach()"? I note that
apparently "detach()" requires data frame names be quoted and "attach()"
requires that they NOT be quoted.
More generally, is it possible to pass symbolic string values to functions
and later cause them to be considered names of variables, names of data
frames, parts of names of data frames (to be manipulated with "paste()"),
or names of ASCII files to be read?
To clarify the need for those who are also SAS users: If I were using SAS
to do this work, I'd use the symbolic variable component of the macro
facility -- defining character strings with "%LET" and causing them to be
evaluated with "&".
Thanks!
--
Michael Prager <Mike.Prager@noaa.gov>
NOAA Center for Coastal Fisheries and Habitat Research
Beaufort, North Carolina 28516
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news