Why not just save your current global environment and reload it after
running the offending code? See ?save.image to save, then rm(list ls()) to clear
the global environment.
If a program tries to get or assign something to a global environment,
then either you rewrite the program to do otherwise, or you rewrite the
assignment functions, as one cannot silo the global environment like
such without writing it to disk (or another environment).
Robert
-----Original Message-----
From: lederer at trium.de [mailto:lederer at trium.de]
Sent: Sunday, January 30, 2005 8:10 PM
To: R-help at stat.math.ethz.ch
Subject: [R] Evaluating code in a sandbox
Dear R-Gurus,
is it possible to evaluate foreign R code in such a safe way, that it
has
no chance to confuse the global environment?
The follwing does not suffice, because the untrusted code might e.g.
contain a superassignment ("<<-"):
connection <- textConnection(some.untrusted.code)
try(eval(parse(connection), envir=new.env()))
close(connection)
Christian
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html