Hi,

Here is how to reproduce:

With a matrix of atomic type
----------------------------

  m1 <- matrix(1:12, ncol=3,
               dimnames=list(letters[1:4], LETTERS[1:3]))

  typeof(m1)
  # [1] "integer"

  m1
  #   A B  C
  # a 1 5  9
  # b 2 6 10
  # c 3 7 11
  # d 4 8 12

  format(m1)
  #   A    B    C
  # a " 1" " 5" " 9"
  # b " 2" " 6" "10"
  # c " 3" " 7" "11"
  # d " 4" " 8" "12"

==> dim and dimnames are propagated.

With a matrix of type "list"
----------------------------

  m2 <- matrix(rep(list(1:5, NULL, "AA"), 4), ncol=3,
               dimnames=list(letters[1:4], LETTERS[1:3]))

  typeof(m2)
  # [1] "list"

  m2
  #   A         B         C
  # a Integer,5 NULL      "AA"
  # b NULL      "AA"      Integer,5
  # c "AA"      Integer,5 NULL
  # d Integer,5 NULL      "AA"

  format(m2)
  # [1] "1, 2, 3, 4, 5" "NULL"          "AA"            "1, 2, 3, 4, 5"
  # [5] "NULL"          "AA"            "1, 2, 3, 4, 5" "NULL"
  # [9] "AA"            "1, 2, 3, 4, 5" "NULL"          "AA"

==> dim and dimnames are dropped!

The same thing seems to happen with arrays of arbitrary dimensions.

Thanks,
H.

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to