Parses expressions in the given file, and then successively evaluates them in the specified environment.
sys.source(file, envir = baseenv(), chdir = FALSE, keep.source = getOption("keep.source.pkgs"))
- a character string naming the file to be read from
- 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
NULLcorresponds to evaluation in the base environment. This is probably not what you want; you should typically supply an explicit
- logical; if
TRUE, the R working directory is changed to the directory containing
- logical. If
TRUE, functions keep their source including comments, see
options(keep.source = *)for more details.
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.
Documentation reproduced from R 3.0.1. License: GPL-2.