1
# File src/library/base/R/eval.R
2
# Part of the R package, http://www.R-project.org
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# A copy of the GNU General Public License is available at
15
# http://www.r-project.org/Licenses/
17
.GlobalEnv <- environment()
18
parent.frame <- function(n = 1) .Internal(parent.frame(n))
21
function(expr, envir = parent.frame(),
22
enclos = if(is.list(envir) || is.pairlist(envir))
23
parent.frame() else baseenv())
24
.Internal(eval(expr, envir,enclos))
26
eval.parent <- function(expr, n = 1){
27
p <- parent.frame(n + 1)
32
function (expr, envir, enclos)
33
eval.parent(substitute(eval(quote(expr), envir, enclos)))
35
new.env <- function (hash=FALSE, parent=parent.frame(), size=29L)
36
.Internal(new.env(hash, parent, size))
38
parent.env <- function(env)
39
.Internal(parent.env(env))
41
"parent.env<-" <- function(env, value)
42
.Internal("parent.env<-"(env, value))
45
function (expr, envir = new.env())
46
eval.parent(substitute(eval(quote(expr), envir)))
48
Recall <- function(...) .Internal(Recall(...))
50
with <- function(data, expr, ...) UseMethod("with")
51
within <- function(data, expr, ...) UseMethod("within")
53
with.default <- function(data, expr, ...)
54
eval(substitute(expr), data, enclos=parent.frame())
55
within.default <- with.default
57
within.data.frame <- function(data, expr, fix=TRUE, inherits=FALSE, ...) {
59
name <- substitute(data)
61
stop("'data' must be a name")
62
name <- as.character(name)
65
parent <- parent.frame()
66
e <- evalq(environment(), data, parent)
68
ret <- eval(substitute(expr), e)
70
del <- setdiff(names(data), names(l))
75
assign(name, data, envir=parent, inherits=inherits)
82
within.list <- within.data.frame
86
force <- function(x) x