[R] manipulating a matrix
David Winsemius
dwinsemius at comcast.net
Wed May 12 21:24:14 CEST 2010
On May 12, 2010, at 3:14 PM, Clark Johnston wrote:
>
> Is there a way to create a new matrix from and existing matrix with
>
> A
> [,1] [,2]
> [1,] 1 13
> [2.] 2 18
> [3,] 3 14
> [4,] 4 20
>
> if()
>
> B
> [,1] [,2]
> [1,] 2 18
> [2,] 4 20
Try (untested absent reproducible example);
A[A[,2] > 15, ]
This (should) create a logical vector in the first argument to "["
which has the effect of returning the rows for which that vector is
TRUE.
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/manipulating-a-matrix-tp2196610p2196610.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list