Martin Maechler
1997-Jul-15 17:02 UTC
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 at stat.math.ethz.ch =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=