### I got bit again by the same bugs I wrote about a year ago.
### The bugs are related to matrices and arrays of lists.
### 1. There is a clear inconsistency in how R handles two
### functionally equivalent statements.
### array() is able to take a list and create a matrix.
### matrix() is unable to create that matrix.
Error in matrix(vector("list", 2), nrow = 2) :
Unimplemented feature in copyVector
### 2. Here the matrix single-[ subscript is doing the wrong thing,
### without giving a warning.
tmp <- array(vector("list", 2), 1:2)
tmp
[,1] [,2]
[1,] "NULL" "NULL"
tmp[1]
[[1]]
NULL
tmp[[1]]
NULL
tmp[1,1]
[[1]]
NULL
tmp[[1,1]]
NULL
list("abc")
[[1]]
[1] "abc"
tmp[1] <- list("abc") ## assignment
tmp[1]
[[1]]
[1] "abc"
tmp[[1]]
[1] "abc"
tmp[1,1] ## incorrect retrieval
[[1]]
NULL
tmp[[1,1]]
[1] "abc"
tmp[1,2] <- list("def") ## refuse to do similar assignment
Error: incompatible types in subset assignment
### 3. subsetting a vector of lists doesn't behave the way I anticipate.
### It looks like NULL is not handled consistently inside a vector.
### Sometimes it can be an element, sometimes not.
tmpv <- vector("list", 2)
tmpv
[[1]]
NULL
[[2]]
NULL
tmpv[1] <- "abcd" ## I assigned to the first element.
tmpv ## Both elements are still here.
[[1]]
[1] "abcd"
[[2]]
NULL
tmpv[1] <- NULL ## I assigned to the first element.
tmpv ## The second element is gone.
[[1]]
NULL
### This time the issue came up in an attempt to make abind work with R.
### abind() is a generalization of rbind and cbind to arrays.
### Tony Plate and I posted it to StatLib in 1996
### (http://lib.stat.cmu.edu/S/abind).
### I would like you to consider adding abind to R.
### The posted abind doesn't work in R, for the reasons above and due to
### a difference in behavior of match.call between S -Plusand R that I am
### reporting in a separate bug report.
### There are two revised files, currently available at
### http://surfer.sbm.temple.edu/~rmh/abind.r
### http://surfer.sbm.temple.edu/~rmh/abind.test.in.r
### The documentation in statlib applies to these files.
### I will update the statlib version after I understand why R differs.
version
_
platform i386-pc-mingw32
arch x86
os Win32
system x86, Win32
status
major 1
minor 4.1
year 2002
month 01
day 30
language R
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._