~showard314/ubuntu/karmic/r-base/remove_start_comments

« back to all changes in this revision

Viewing changes to src/library/base/R/eval.R~

  • Committer: Bazaar Package Importer
  • Author(s): Dirk Eddelbuettel
  • Date: 2009-01-19 12:40:24 UTC
  • mfrom: (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090119124024-abxsf4e0y7713w9m
Tags: 2.8.1-2
debian/control: Add another Build-Depends: exclusion for the 
'kfreebsd-i386 kfreebsd-amd64 hurd-i386' architecture to openjdk-6-jdk.
Thanks to Petr Salinger for the heads-up.               (Closes: 512324)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#  File src/library/base/R/eval.R
 
2
#  Part of the R package, http://www.R-project.org
 
3
#
 
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.
 
8
#
 
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.
 
13
#
 
14
#  A copy of the GNU General Public License is available at
 
15
#  http://www.r-project.org/Licenses/
 
16
 
 
17
.GlobalEnv <- environment()
 
18
parent.frame <- function(n = 1) .Internal(parent.frame(n))
 
19
 
 
20
eval <-
 
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))
 
25
 
 
26
eval.parent <- function(expr, n = 1){
 
27
    p <- parent.frame(n + 1)
 
28
    eval(expr , p)
 
29
}
 
30
 
 
31
evalq <-
 
32
    function (expr, envir, enclos)
 
33
    eval.parent(substitute(eval(quote(expr), envir, enclos)))
 
34
 
 
35
new.env <- function (hash=FALSE, parent=parent.frame(), size=29L)
 
36
    .Internal(new.env(hash, parent, size))
 
37
 
 
38
parent.env <- function(env)
 
39
    .Internal(parent.env(env))
 
40
 
 
41
"parent.env<-" <- function(env, value)
 
42
    .Internal("parent.env<-"(env, value))
 
43
 
 
44
local <-
 
45
    function (expr, envir = new.env())
 
46
    eval.parent(substitute(eval(quote(expr), envir)))
 
47
 
 
48
Recall <- function(...) .Internal(Recall(...))
 
49
 
 
50
with <- function(data, expr, ...) UseMethod("with")
 
51
within <- function(data, expr, ...) UseMethod("within")
 
52
 
 
53
with.default <- function(data, expr, ...)
 
54
    eval(substitute(expr), data, enclos=parent.frame())
 
55
within.default <- with.default
 
56
 
 
57
within.data.frame <- function(data, expr, fix=TRUE, inherits=FALSE, ...) {
 
58
    if (fix) {
 
59
        name <- substitute(data)
 
60
        if (!is.name(name))
 
61
            stop("'data' must be a name")
 
62
        name <- as.character(name)
 
63
    }
 
64
 
 
65
    parent <- parent.frame()
 
66
    e   <- evalq(environment(), data, parent)
 
67
 
 
68
    ret <- eval(substitute(expr), e)
 
69
    l   <- as.list(e)
 
70
    del <- setdiff(names(data), names(l))
 
71
    data[names(l)] <- l
 
72
    data[del] <- NULL
 
73
 
 
74
    if (fix) {
 
75
        assign(name, data, envir=parent, inherits=inherits)
 
76
        invisible(ret)
 
77
    }
 
78
    else
 
79
        data
 
80
}
 
81
 
 
82
within.list <- within.data.frame
 
83
 
 
84
 
 
85
 
 
86
force <- function(x) x