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] > Xa 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] > Xa 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk writes:> 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.Hmm. This is a consequence of> x<-NULL > x[[2]]<- letters[1:2]Error: more elements supplied than there are to replace which S-PLUS does differently. However, I'm not sure we really want this to change for the following reason:> x<-NULL > x[[2]]<- letters[1:2] > x$"": NULL $value: [1] "a" "b"> x<-NULL > x[[2]]<-"1" > x[1] "" "1" Now what does this do if the array extent has length 1?> x <- matrix(1:2,2) > dimnames(X)[[2]] <- "a"Problem in dimnames(X) <- .A0: Component 2 of dimnames has length 1, should be 2 Use traceback() to see the call stack -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Apparently Analagous Threads
- empty array indexing with dimnames (PR#2507)
- [wishlist, patch] make row() and col() preserve dimnames (PR#13705)
- (PR#9623) qr.coef: permutes dimnames; inserts NA; promises
- editor in Windows doesn't like a data frame with row names (PR#798)
- which() does not handle NAs in named vectors. (PR#226)