Movatterモバイル変換


[0]ホーム

URL:


rdrr.io

sys.source: Parse and Evaluate Expressions from a File

sys.sourceR Documentation

Parse and Evaluate Expressions from a File

Description

Parses expressions in the given file, and then successively evaluatesthem in the specified environment.

Usage

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))

Arguments

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 valueNULL corresponds to evaluation in the baseenvironment. This is probably not what you want; you shouldtypically supply an explicitenvir argument.

chdir

logical; ifTRUE, theR working directory ischanged to the directory containingfile for evaluating.

keep.source

logical. IfTRUE, functions keeptheir source including comments, seeoptions(keep.source = *) for more details.

keep.parse.data

logical. IfTRUE andkeep.source isalsoTRUE, functions keep parse data with their source, seeoptions(keep.parse.data = *) for more details.

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

Details

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.

See Also

source, andlibrary which usessys.source.

Examples

## 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")

What can we improve?

R Package Documentation

Browse R Packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that.

 
Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, readEmbedding Snippets.

Close

[8]ページ先頭

©2009-2025 Movatter.jp