[R] search through a matrix
David Winsemius
dwinsemius at comcast.net
Tue Apr 21 15:38:20 CEST 2009
On Apr 21, 2009, at 9:02 AM, onyourmark wrote:
>
> Hi again. Thanks. I get it now.
> So row(x) is a matrix with just the row number for each entry.
Yes.
>
>
> How about x[row(x) == col(x)] ?
> Can the square bracket function take a matrix as its argument? If
> so, I
> guess I understand this statement.
> The argument is a boolean matrix.
It can and it often does. The argument to the [] operation can be
either a logical vector or a numeric vector which gets treated as an
index. Try x[8]. My understanding is that the matrix, row(x) ==
col(x), as an argument would first get coerced to a vector constructed
from the column-wise projection of the matrix. You can read further on
the help page in the section that discusses matrices and arrays:
?"["
>
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list