R-beta: dimnames(obj)[..] <- .... works in S but not in R

Martin Maechler (maechler@stat.math.ethz.ch)
Tue, 15 Jul 1997 19:02:59 +0200


Date: Tue, 15 Jul 1997 19:02:59 +0200
Message-Id: <199707151702.TAA01993@sophie.ethz.ch>
From: Martin Maechler <maechler@stat.math.ethz.ch>
To: R-help@stat.math.ethz.ch
Subject: R-beta: dimnames(obj)[..] <- ....   works in S  but not in R

The following is a minor incompatibility  R <-> S
which may  be worth putting on the  TASKS list :

-- Martin Maechler


###--- The following code only works in  S, but not in R :

##-- Example 1 :   dimnames(..)[.] <-  list(...)
##                             ===
ma <- cbind(1,1:4)
dimnames(ma)[2] <- list(c("x","y"))
ma
##-      x y 
##- [1,] 1 1
##- [2,] 1 2
##- [3,] 1 3
##- [4,] 1 4


##-- Example 2 :   dimnames(..)[[.]] <- ...  
##                             =====	       works when dimnames(.) != NULL
mb <- rbind(x = 1, y = 1:4)
dimnames(mb)[[2]] <- paste("V",1:4, sep='.')
mb
##-   V.1 V.2 V.3 V.4 
##- x   1   1   1   1
##- y   1   2   3   4


###--- The following examples don't work either in S  -- and maybe rightly so.

##-- Example 3a :  dimnames(..)[[.]] <- ...  
##                             =====	       FAILS, since  dimnames(.) == NULL
mc <- rbind( 1,  1:4)
dimnames(mc)[[2]] <- paste("V",1:4, sep='.')
mc

##-- Example 3b :  dimnames(..)[[.]] <- ...  
##                             =====	       FAILS, since  dimnames(.) == NULL
mc <- cbind( 1,  1:4)
dimnames(mc)[[1]] <- paste("V",1:4, sep='.')
mc
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-help 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-help-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=