The R Project SVN R

Rev

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

Rev 27362 Rev 28176
Line 90... Line 90...
90
  The functions \code{.subset} and \code{.subset2} are essentially
90
  The functions \code{.subset} and \code{.subset2} are essentially
91
  equivalent to the \code{[} and \code{[[} operators, except that
91
  equivalent to the \code{[} and \code{[[} operators, except that
92
  methods dispatch does not take place.  This is to avoid expensive
92
  methods dispatch does not take place.  This is to avoid expensive
93
  unclassing when applying the default method to an object.  They
93
  unclassing when applying the default method to an object.  They
94
  should not normally be invoked by end users.
94
  should not normally be invoked by end users.
-
 
95
 
-
 
96
  As from \R 1.9.0 both \code{$} and \code{[[} can be applied to
-
 
97
  environments. Only character arguments are allowed and no partial
-
 
98
  matching is done (this is in contrast to the behavior for lists). The
-
 
99
  semantics of these operations is basically that of \code{get(i, env=x,
-
 
100
    inherits=FALSE)}. If no match is found then \code{NULL} is
-
 
101
  returned. The assignment versions, \code{$<-} and
-
 
102
  \code{[[<-}, can also be used. Again, only character arguments are
-
 
103
  allowed and no partial matching is done. The semantics in this case
-
 
104
  are those of \code{assign(i, value, env=x, inherits=FALSE)}. Such an
-
 
105
  assignment will either create a new binding or change the existing
-
 
106
  binding in \code{x}.
95
}
107
}
96
\references{
108
\references{
97
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
109
  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
98
  \emph{The New S Language}.
110
  \emph{The New S Language}.
99
  Wadsworth \& Brooks/Cole.
111
  Wadsworth \& Brooks/Cole.
Line 130... Line 142...
130
unlist(z)
142
unlist(z)
131
z[[c(1, 2)]]
143
z[[c(1, 2)]]
132
z[[c(1, 2, 1)]]  # both "hello"
144
z[[c(1, 2, 1)]]  # both "hello"
133
z[[c("a", "b")]] <- "new"
145
z[[c("a", "b")]] <- "new"
134
unlist(z)
146
unlist(z)
-
 
147
 
-
 
148
##check $ and [[ for environments
-
 
149
e1 <- new.env()
-
 
150
e1$a <- 10
-
 
151
e1[["a"]]
-
 
152
e1[["b"]] <- 20
-
 
153
e1$b
-
 
154
ls(e1)
135
}
155
}
136
\keyword{array}
156
\keyword{array}
137
\keyword{list}
157
\keyword{list}