From hb at stat.berkeley.edu  Wed Mar  7 01:39:12 2007
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Tue, 6 Mar 2007 16:39:12 -0800
Subject: [Rd] Reordering the search path?
Message-ID: <59d7961d0703061639i2b0a6daaycb8233a4973fa2df@mail.gmail.com>

Hi, without arguing for doing it or not, is the following a correct
way to reorder the search path:

moveInSearchPath <- function(from, to) {
  # Excluding validation of 'from' and 'to' here etc.

  # Get enviroment to be moved
  env <- pos.to.env(from);

  # Detach old position without side effects, cf. detach().
  .Internal(detach(from));

  if (to > from)
    to <- to - 1;

  # Attach at new position
  attach(env, pos=to, name=attr(env, "name"));
}

Thanks

/Henrik



[Rd] Reordering the search path?
Henrik Bengtsson