[R] matrix lists

Prof Brian D Ripley
Tue, 26 Feb 2002 12:19:36 -0000

Perhaps the following example will help demonstrate that matrix lists do
exist and do work up to a point, despite strident assertions on R-help to
the contrary:

> m <- list(a1=1:3, a2=4:6, a3=pi,
a4=c("a","b","c"))
> dim(m) <- c(2,2)
> m
     [,1]        [,2]
[1,] "Numeric,3" "Numeric,1"
[2,] "Numeric,3" "Character,3"
> is.matrix(m)
[1] TRUE
> m[[1,2]]
[1] 3.141593
> m[[2,2]]
[1] "a" "b" "c"

In S m[2,2] extracts a sub-list, but that seems not to work correctly in R:
neither does m[,2].  I am reporting that as a bug.

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595