Re: [R] logical masking of a matrix converts it to a vector

2009-12-04 Thread David Winsemius
On Dec 4, 2009, at 4:03 PM, Jorge Ivan Velez wrote: Hi Austin, What version of R are you using? It works for me for R 2.10.0 Patched on Win XP Pro: R> a <- matrix(c(1, 2, 3, 4), nrow = 2) R> a # [1] 1 3 # [2] 2 4 R> rmask <- c(TRUE, FALSE) R> a[rmask,] # [1] 1 3 Doesn't work on a Mac (ad

Re: [R] logical masking of a matrix converts it to a vector

2009-12-04 Thread Jorge Ivan Velez
Hi Austin, What version of R are you using? It works for me for R 2.10.0 Patched on Win XP Pro: R> a <- matrix(c(1, 2, 3, 4), nrow = 2) R> a # [1] 1 3 # [2] 2 4 R> rmask <- c(TRUE, FALSE) R> a[rmask,] # [1] 1 3 HTH, Jorge On Fri, Dec 4, 2009 at 3:52 PM, Austin Huang <> wrote: > One problem I'

Re: [R] logical masking of a matrix converts it to a vector

2009-12-04 Thread Ravi Varadhan
Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Austin Huang Sent: Friday, December 04, 2009 3:52 PM To: R-help@r-project.org Subject: [R] logical maski

Re: [R] logical masking of a matrix converts it to a vector

2009-12-04 Thread Phil Spector
b <- a[rmask,,drop=FALSE] - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley

Re: [R] logical masking of a matrix converts it to a vector

2009-12-04 Thread Erik Iverson
> One problem I've been having is the special case in which only one > row/column remains and the variable gets converted into a vector when > entries are removed by logical masking. This is a problem because > subsequent > code may rely on matrix operations (apply, colsums, dim, etc) For example:

Re: [R] logical masking of a matrix converts it to a vector

2009-12-04 Thread David Winsemius
On Dec 4, 2009, at 3:52 PM, Austin Huang wrote: One problem I've been having is the special case in which only one row/column remains and the variable gets converted into a vector when entries are removed by logical masking. This is a problem because subsequent code may rely on matrix operati

[R] logical masking of a matrix converts it to a vector

2009-12-04 Thread Austin Huang
One problem I've been having is the special case in which only one row/column remains and the variable gets converted into a vector when entries are removed by logical masking. This is a problem because subsequent code may rely on matrix operations (apply, colsums, dim, etc) For example: > a <- ma