| sys.source | R Documentation |
Parses expressions in the given file, and then successively evaluatesthem in the specified environment.
sys.source(file, envir = baseenv(), chdir = FALSE, keep.source = getOption("keep.source.pkgs"), keep.parse.data = getOption("keep.parse.data.pkgs"), toplevel.env = as.environment(envir))file | a character string naming the file to be read from |
envir | anR object specifying the environment in which theexpressions are to be evaluated. May also be a list or an integer.The default value |
chdir | logical; if |
keep.source | logical. If |
keep.parse.data | logical. If |
toplevel.env | anR environment to be used as top level whileevaluating the expressions. This argument is useful for frameworksrunning package tests; the default should be used in other cases |
For large files,keep.source = FALSE may save quite a bit ofmemory. Disabling only parse data viakeep.parse.data = FALSEcan already save a lot.In order for the code being evaluated to use the correct environment(for example, in global assignments), source code in packages shouldcalltopenv(), which will return the namespace, if any,the environment set up bysys.source, or the global environmentif a saved image is being used.
source, andlibrary which usessys.source.
## a simple way to put some objects in an environment## high on the search pathtmp <- tempfile()writeLines("aaa <- pi", tmp)env <- attach(NULL, name = "myenv")sys.source(tmp, env)unlink(tmp)search()aaadetach("myenv")Add the following code to your website.
For more information on customizing the embed code, readEmbedding Snippets.
