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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to