[Rd] cannot assign to NULL dimnames (PR#1042)

htang@hpl.hp.com htang@hpl.hp.com
Tue, 7 Aug 2001 21:14:51 +0200 (MET DST)


Full_Name: Hsiu-Khuern Tang
Version: 1.3.0
OS: GNU/Linux (Debian unstable)
Submission from: (NULL) (192.6.19.124)


Hi all,

    I am not sure this is a bug rather than an intentional design, but here
goes:
If I do

> a <- matrix(1:4, nrow=2)
> dimnames(a)[[1]] <- c("a", "b")

I get the following error message because dimnames(a) is NULL:

Error: more elements supplied than there are to replace

What is the proper way to do this?  I know this works:

> dimnames(a) <- list(c("a", "b"), NULL)

   Incidentally, in SPlus, I can assign to NULL dimnames.

Thanks,
Hsiu-Khuern.

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