Skip to content
Prev 172344 / 398506 Next

Error setting rowname if rowname currently NULL

snubian wrote:
<snip>
... and

    rownames(fred)
    # NULL
... so now rownames(fred) would have to become a vector of length one,
and you're trying to use a vector of length one to name rows in a matrix
with four rows.  (in principle, you could argue that the vector should
be recycled on such an occassion, as it happens in many other situations.)

hence
... because 1 != 4
... so that length(rownames(fred)) == 4
... whereby you change one element in rownames(fred) and it still has 4
elements
not exactly true:

    fred = matrix(, 4, 2)
    rownames(fred)[4] = 'foo'

here you'd set the 4th element of rownames(fred), which fill the first
three with NA, and rownames(fred) has length 4, as needed.
is it possible that you don't really need it?

vQ