ripley@stats.ox.ac.uk
2002-Feb-26 12:25 UTC
[Rd] subscripting problems with matrix lists (PR#1329)
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._