as.list

Kjetil Halvorsen khal@alumni.uv.es
Tue, 24 Nov 1998 17:05:47 +0100


I don't understand the behavior of "as.list"
(really as.list.default) on arguments which
are expressions. An artificial example:

> as.list(expression( x <- 1, y <- 2))
[[1]]
<-

[[2]]
<-

as.list.default contains the following code:

 if (is.expression(x)) {
        l <- vector("list")
        for (sub in x) l <- c(l, sub[[1]])

--- why the sub[[1]] part?

eliminating the [[1]], I get:

> my.as.list(expression( x <- 1, y <- 2))
[[1]]
x <- 1

[[2]]
y <- 2


Kjetil Halvorsen
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._