[Rd] dimnames(X)[[2]] <- foo fails (PR#1122)

ripley@stats.ox.ac.uk ripley@stats.ox.ac.uk
Tue, 9 Oct 2001 17:10:23 +0200 (MET DST)


Since this works in recent S-PLUS and is not in the FAQ as a difference, I
presume it is an unintentional one.  If it is intentional, this is for the
wishlist that this be removed.

S-PLUS (6.0)
> X <- matrix(1:4, 2, 2)
> dimnames(X)[[2]] <- letters[1:2]
> X
     a b
[1,] 1 3
[2,] 2 4

R 1.3.1
> X <- matrix(1:4, 2, 2)
> dimnames(X)[[2]] <- letters[1:2]
Error: more elements supplied than there are to replace
> colnames(X) <- 1:2
> dimnames(X)[[2]] <- letters[1:2]
> X
     a b
[1,] 1 3
[2,] 2 4

which is none too obvious an error message, and somewhat inconsistent.


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