[Rd] Unexpected dimnames attribute returned by cbind/rbind

Hervé Pagès hpages at fredhutch.org
Fri Dec 22 09:57:10 CET 2017


Hi,

   > m5 <- cbind(integer(5), integer(5))
   > m5
        [,1] [,2]
   [1,]    0    0
   [2,]    0    0
   [3,]    0    0
   [4,]    0    0
   [5,]    0    0
   > dimnames(m5)
   NULL

No dimnames, as expected.

   > m0 <- cbind(integer(0), integer(0))
   > m0
        [,1] [,2]
   > dimnames(m0)
   [[1]]
   NULL

   [[2]]
   NULL

Unexpected dimnames attribute!

rbind'ing empty vectors also returns a matrix with unexpected
dimnames:

   > dimnames(rbind(character(0), character(0)))
   [[1]]
   NULL

   [[2]]
   NULL

Cheers,
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: hpages at fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the R-devel mailing list