-
Notifications
You must be signed in to change notification settings - Fork 2
/
globalsByName.Rd
76 lines (59 loc) 路 1.75 KB
/
globalsByName.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/globalsByName.R
\name{globalsByName}
\alias{globalsByName}
\title{Locates and retrieves a set of global variables by their names}
\usage{
globalsByName(names, envir = parent.frame(), mustExist = TRUE, ...)
}
\arguments{
\item{names}{A character vector of global variable names.}
\item{envir}{The environment from where to search for globals.}
\item{mustExist}{If TRUE, an error is thrown if the object of the
identified global cannot be located. Otherwise, the global
is not returned.}
\item{...}{Not used.}
}
\value{
A \link{Globals} object of named elements and an attribute
\code{where} with named elements. Both of sets have names according to
\code{names}.
}
\description{
Locates and retrieves a set of global variables by their names
}
\section{Special "argument" globals}{
If \code{names} specifies \code{"..."}, \code{"..1"}, \code{"..2"}, ..., then they
are interpreted as arguments \code{...}, \code{..1}, \code{..2}, ..., respectively.
If specified, then the corresponding elements in the results are
lists of class \code{DotDotDotList} comprising the value of the latter.
If the special argument does not exist, then the value is \code{NA}, and
the corresponding \code{where} attributes is \code{NULL}.
}
\examples{
f <- function(x = 42, ...) {
globalsByName("x")
}
globals <- f()
str(globals)
globals <- f(3.14)
str(globals)
g <- function(x = 42, ...) {
globalsByName("...")
}
globals <- g()
str(globals)
globals <- g(3.14)
str(globals)
globals <- g(3.14, 1L, b = 2L, c = 3L)
str(globals)
h <- function(x = 42, ...) {
globalsByName("..2")
}
globals <- h(x = 3.14, a = 1, b = 2)
str(globals)
globals <- g(3.14)
str(globals)
globals <- g(3.14, 1L, b = 2L, c = 3L)
str(globals)
}