[Rd] Question about colnames behavior

Martin Maechler maechler at stat.math.ethz.ch
Mon Oct 3 10:28:51 CEST 2005


>>>>> "Erich" == Erich Neuwirth <erich.neuwirth at univie.ac.at>
>>>>>     on Sun, 02 Oct 2005 09:39:36 +0200 writes:

    Erich> The following code
    Erich> zzz<-1:10
    Erich> dim(zzz)<-10
    Erich> rownames(zzz)
    Erich> colnames(zzz)

    Erich> yields NULL for the rownames and colnames calls.
    Erich> Let us set rownames

    Erich> rownames(zzz)<-1:10

    Erich> Now rownames(zzz) returns the expected result, but colnames(zzz)
    Erich> produces an error:
    Erich> Error in dn[[2]] : subscript out of bounds

    Erich> So given a onedimensional structure the return behavior of colnames
    Erich> is different depending on the fact if rownames are set or not.

    Erich> Should the behavior of colnames be changed to make the result
    Erich> independent from this fact?

yes, thank you, Erich. 
It should give an error also in the 1st  case which is
BTW identical to  
    zzz <- array(1:10)

Not for R 2.2.0 though, but rather 2.2.1.

Martin



More information about the R-devel mailing list