Skip to content

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

2 messages · Brian Ripley, Peter Dalgaard

#
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)
a b
[1,] 1 3
[2,] 2 4

R 1.3.1
Error: more elements supplied than there are to replace
a b
[1,] 1 3
[2,] 2 4

which is none too obvious an error message, and somewhat inconsistent.
#
ripley@stats.ox.ac.uk writes:
Hmm. This is a consequence of
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:
$"":
NULL

$value:
[1] "a" "b"
[1] ""  "1"

Now what does this do if the array extent has length 1?
Problem in dimnames(X) <- .A0: Component 2 of dimnames has length 1, should be 2 
Use traceback() to see the call stack