Description Usage Arguments Details See Also Examples
Parses expressions in the given file, and then successively evaluates them in the specified environment.
1 2 | sys.source(file, envir = baseenv(), chdir = FALSE,
keep.source = getOption("keep.source.pkgs"))
|
file |
a character string naming the file to be read from |
envir |
an R object specifying the environment in which the
expressions are to be evaluated. May also be a list or an integer.
The default value |
chdir |
logical; if |
keep.source |
logical. If |
For large files, keep.source = FALSE
may save quite a bit of
memory.
In order for the code being evaluated to use the correct environment
(for example, in global assignments), source code in packages should
call topenv()
, which will return the namespace, if any,
the environment set up by sys.source
, or the global environment
if a saved image is being used.
source
, and library
which uses
sys.source
.
1 2 3 4 5 6 7 8 9 10 | ## a simple way to put some objects in an environment
## high on the search path
tmp <- tempfile()
writeLines("aaa <- pi", tmp)
env <- attach(NULL, name = "myenv")
sys.source(tmp, env)
unlink(tmp)
search()
aaa
detach("myenv")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.