The R Project SVN R

Rev

Rev 25543 | Rev 28503 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25543 Rev 26568
Line 1... Line 1...
1
\name{get}
1
\name{get}
2
\alias{get}
2
\alias{get}
3
\title{Return a Variable's Value}
3
\title{Return the Value of a Named Object}
4
\description{
4
\description{
5
  Search for an \R object with a given name and return it if found.
5
  Search for an \R object with a given name and return it.
6
}
6
}
7
 
-
 
8
\usage{
7
\usage{
9
get(x, pos=-1, envir=as.environment(pos), mode="any", inherits=TRUE)
8
get(x, pos=-1, envir=as.environment(pos), mode="any", inherits=TRUE)
10
}
9
}
11
\arguments{
10
\arguments{
12
  \item{x}{a variable name (given as a character string).}
11
  \item{x}{a variable name (given as a character string).}
13
  \item{pos}{where to look for the object (see the details section); if
12
  \item{pos}{where to look for the object (see the details section); if
14
    omitted, the function will search, as if the name of the object
13
    omitted, the function will search as if the name of the object
15
    appeared in unquoted in an expression.
14
    appeared unquoted in an expression.}
16
  }
-
 
17
  \item{envir}{an alternative way to specify an environment to look in;
15
  \item{envir}{an alternative way to specify an environment to look in;
18
    see the details section.}
16
    see the details section.}
19
  \item{mode}{the mode of object sought.}
17
  \item{mode}{the mode of object sought.}
20
  \item{inherits}{should the enclosing frames of the environment be
18
  \item{inherits}{should the enclosing frames of the environment be
21
    inspected?}
19
    searched?}
22
}
20
}
23
\details{
21
\details{
24
  The \code{pos} argument can specify the  environment in which to look
22
  The \code{pos} argument can specify the environment in which to look
25
  for the object in any of several ways:
23
  for the object in any of several ways: as an integer (the position in
26
  as an integer (the position in the \code{\link{search}} list); as
-
 
27
  the character string name of an element in the search list; or as an
24
  the \code{\link{search}} list); as the character string name of an
28
  \code{\link{environment}} (including using \code{\link{sys.frame}} to
25
  element in the search list; or as an \code{\link{environment}}
29
  access the currently active function calls).
26
  (including using \code{\link{sys.frame}} to access the currently active
30
  The \code{envir} argument is an alternative way to specify an
27
  function calls).  The \code{envir} argument is an alternative way to
31
  environment, but is primarily there for back compatibility.
28
  specify an environment, but is primarily there for back compatibility.
32
  
29
 
-
 
30
  This function looks to see if the name \code{x} has a value bound to
33
   The \code{mode} includes collections such as \code{"numeric"} and
31
  it in the specified environment. If \code{inherits} is \code{TRUE} and
34
   \code{"function"}: any member of the collection will suffice. 
32
  a value is not found for \code{x} in the specified environment, the
35
}
-
 
36
\value{
-
 
37
  This function searches the specified environment for a bound variable
33
  enclosing frames of the environment (and the search path) are searched
38
  whose name is given by the character string \code{x}.  If the
34
  until the name \code{x} is encountered.  \bold{Warning:}
39
  variable's value is not of the correct \code{mode}, it is ignored.
35
  \code{inherits=TRUE} is the default behaviour for \R but not for S.
40
 
36
 
41
  If \code{inherits} is \code{FALSE}, only the first frame of the
-
 
42
  specified environment is inspected.  If \code{inherits} is
37
  The \code{mode} may specify collections such as \code{"numeric"} and
43
  \code{TRUE}, the search is continued up through the parent frames
-
 
44
  until a bound value of the right mode is found.
38
  \code{"function"}: any member of the collection will suffice.
45
 
39
 
46
  Using a \code{NULL} environment is equivalent to using the current
40
  Using a \code{NULL} environment is equivalent to using the current
47
  environment.
41
  environment.
48
}
42
}
-
 
43
\value{
-
 
44
  The object found.  (If no object is found an error results.)
-
 
45
}
49
\references{
46
\references{
50
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
47
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
51
  \emph{The New S Language}.
48
  \emph{The New S Language}.
52
  Wadsworth \& Brooks/Cole.
49
  Wadsworth \& Brooks/Cole.
53
}
50
}