Re: [R] when deleting a row from a matrix gives a vector

2007-11-02 Thread Thomas Lumley
On Fri, 2 Nov 2007, Gabriel Valiente wrote: > Is there any way to force the result to remain a matrix, even if it > has only one row or column, or even only one entry? Thanks, > Yes. See the FAQ entry or the help page. -thomas Thomas Lumley Assoc. Professor, Biostatist

Re: [R] when deleting a row from a matrix gives a vector

2007-11-02 Thread Vijay Vaidyanathan
On Nov 2, 2007, at 12:50 PM, Sarah Goslee wrote: > x <- x[1, drop=FALSE] > >> Is there any way to force the result to remain a matrix, even if it >> has only one row or column, or even only one entry? Thanks, I think you might have meant ... x <- x[1,,drop=FALSE] Note the double commas ... - VV

Re: [R] when deleting a row from a matrix gives a vector

2007-11-02 Thread Marc Schwartz
On Fri, 2007-11-02 at 20:47 +0100, Gabriel Valiente wrote: > Deleting a row from a matrix turns it into a vector (and dim names > are lost) if the resulting matrix has only one row or column. For > instance: > > > x <- matrix(1:10, ncol=2) > > x <- x[1,] > > turns x into > > [1] 1 6 > > i

Re: [R] when deleting a row from a matrix gives a vector

2007-11-02 Thread Sarah Goslee
x <- x[1, drop=FALSE] > Is there any way to force the result to remain a matrix, even if it > has only one row or column, or even only one entry? Thanks, -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://s

[R] when deleting a row from a matrix gives a vector

2007-11-02 Thread Gabriel Valiente
Deleting a row from a matrix turns it into a vector (and dim names are lost) if the resulting matrix has only one row or column. For instance: > x <- matrix(1:10, ncol=2) > x <- x[1,] turns x into [1] 1 6 instead of [,1] [,2] [1,]16 Is there any way to force the result to