The R Project SVN R

Rev

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

Rev 72237 Rev 73898
Line 15... Line 15...
15
  possibly modifying (a copy of) the original data.
15
  possibly modifying (a copy of) the original data.
16
}
16
}
17
\usage{
17
\usage{
18
with(data, expr, \dots)
18
with(data, expr, \dots)
19
within(data, expr, \dots)
19
within(data, expr, \dots)
-
 
20
\S3method{within}{list}(data, expr, keepAttrs = TRUE, \dots)
20
}
21
}
21
\arguments{
22
\arguments{
22
  \item{data}{data to use for constructing an environment. For the
23
  \item{data}{data to use for constructing an environment. For the
23
    default \code{with} method this may be an environment, a list, a
24
    default \code{with} method this may be an environment, a list, a
24
    data frame, or an integer as in \code{sys.call}. For \code{within},
25
    data frame, or an integer as in \code{sys.call}. For \code{within},
25
    it can be a list or a data frame.}
26
    it can be a list or a data frame.}
26
  \item{expr}{expression to evaluate.}
27
  \item{expr}{expression to evaluate; particularly for \code{within()}
-
 
28
    often a \dQuote{compound} expression, i.e., of the form \preformatted{   {
-
 
29
     a <- somefun()
-
 
30
     b <- otherfun()
-
 
31
     .....
-
 
32
     rm(unused1, temp)
-
 
33
   }
-
 
34
}}
-
 
35
  \item{keepAttrs}{for the \code{\link{list}} method of \code{within()},
-
 
36
    a \code{\link{logical}} specifying if the resulting list should keep
-
 
37
    the \code{\link{attributes}} from \code{data} and have its
-
 
38
    \code{\link{names}} in the same order.  Often this is unneeded as
-
 
39
    the result is a \emph{named} list anyway, and then \code{keepAttrs =
-
 
40
      FALSE} is more efficient.}
27
  \item{\dots}{arguments to be passed to future methods.}
41
  \item{\dots}{arguments to be passed to (future) methods.}
28
}
42
}
29
\details{
43
\details{
30
  \code{with} is a generic function that evaluates \code{expr} in a
44
  \code{with} is a generic function that evaluates \code{expr} in a
31
  local environment constructed from \code{data}.  The environment has
45
  local environment constructed from \code{data}.  The environment has
32
  the caller's environment as its parent.  This is useful for
46
  the caller's environment as its parent.  This is useful for
Line 88... Line 102...
88
    S.cT <- Solar.R / cTemp  # using the newly created variable
102
    S.cT <- Solar.R / cTemp  # using the newly created variable
89
    rm(Day, Temp)
103
    rm(Day, Temp)
90
})
104
})
91
head(aq)
105
head(aq)
92
 
106
 
-
 
107
 
-
 
108
 
-
 
109
 
93
# example from boxplot:
110
# example from boxplot:
94
with(ToothGrowth, {
111
with(ToothGrowth, {
95
    boxplot(len ~ dose, boxwex = 0.25, at = 1:3 - 0.2,
112
    boxplot(len ~ dose, boxwex = 0.25, at = 1:3 - 0.2,
96
            subset = (supp == "VC"), col = "yellow",
113
            subset = (supp == "VC"), col = "yellow",
97
            main = "Guinea Pigs' Tooth Growth",
114
            main = "Guinea Pigs' Tooth Growth",