Skip to content
Prev 18111 / 63424 Next

Antwort: Re: Inconsistency with matrix indexing (PR#8214)

On 10/18/2005 9:32 AM, stefan.albrecht at allianz.com wrote:
I don't agree with your suggestion.  mat[1, , drop = FALSE] is a  1x3 
matrix, with both row and column names.  Indexing it by [1] says that 
you want to treat it as a vector, and give the first element.  How could 
R know whether to keep the row or column name for that [1,1] element? 
What should it do with the expression

mat[1,1 , drop = FALSE][1]

?

If you are really concerned about the names, you should use matrix 
indexing in both places with drop = FALSE:

 > mat[1, , drop = FALSE][1,1,drop=FALSE]
    c1
r1  1

Duncan Murdoch