On Fri, 4 Jul 2008, Ulrich Leopold wrote:
Dear list,
is there a way of updating the search path when using attach() for a data set.
I am overwriting a variable in a data frame. To update teh search path I do
the follwoing:
attach(dataset)
some data manipulation of dataset
detach(dataset)
attach(dataset) # to update the search path
Is there a way to avoid the numerous detach() and attach() commands?
Not if 'dataset' is that data frame (you didn't actually say). From the
help page:
The database is not actually attached. Rather, a new environment
is created on the search path and the elements of a list
(including columns of a data frame) or objects in a save file or
an environment are _copied_ into the new environment. If you use
'<<-' or 'assign' to assign to an attached database, you only
alter the attached copy, not the original object.
So you can both change the data frame and assign the column to pos=2 to
get the effect of what you appear to want.
Thanks in advance,
Ulrich Leopold
--
Brian D. Ripley, [EMAIL PROTECTED]
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
______________________________________________
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.