From ripley@stats.ox.ac.uk  Tue Feb 26 12:25:30 2002
From: ripley@stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Tue, 26 Feb 2002 13:25:30 +0100 (MET)
Subject: [Rd] subscripting problems with matrix lists (PR#1329)
Message-ID: <200202261225.NAA18768@pubhealth.ku.dk>

R 1.4.1 (and R-devel)
> 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"
> m[[1,2]]
[1] 3.141593
> m[[2,2]]
[1] "a" "b" "c"

correct so far, but
> m[2,2]
[[1]]
NULL

> m[,2]
[[1]]
NULL

[[2]]
NULL

which are lists of the correct length but wrong content.

This works correctly in S:
> 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 3.1416
[2,] numeric, 3 character, 3
> m[[1,2]]
[1] 3.1416
> m[[2,2]]
[1] "a" "b" "c"
> m[2,2]
$a4:
[1] "a" "b" "c"

> m[,2]
$a3:
[1] 3.1416

$a4:
[1] "a" "b" "c"

The printout is a little better, too.

-- 
Brian D. Ripley,                  ripley@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


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] subscripting problems with matrix lists (PR#1329)
ripley@stats.ox.ac.uk