Re: [R] Removing rows of zeros from a matrix

2011-06-23 Thread David Winsemius
On Jun 2, 2011, at 11:35 AM, Petr Savicky wrote: On Thu, Jun 02, 2011 at 11:23:28AM -0400, Jim Silverton wrote: Hi, Can someone tell me how to remove rows of zeros from a matrix? For example if I have the following matrix, 0 0 0 1 2 8 0 0 4 56 I should end up with 0 1 2 8 4 56 Hi. Try the

Re: [R] Removing rows of zeros from a matrix

2011-06-02 Thread Petr Savicky
On Thu, Jun 02, 2011 at 11:23:28AM -0400, Jim Silverton wrote: > Hi, > Can someone tell me how to remove rows of zeros from a matrix? > For example if I have the following matrix, > > 0 0 > 0 1 > 2 8 > 0 0 > 4 56 > > I should end up with > 0 1 > 2 8 > 4 56 Hi. Try the following a <- matrix(c

Re: [R] Removing rows of zeros from a matrix

2011-06-02 Thread Jonathan Daily
Assuming the matrix is named X: X[which(rowSums(X) > 0),] should work. Also, this list is a text-only list. As you are using gmail, sending text only messages is very easy, and may clear confusion in future posts. HTH, Jon On Thu, Jun 2, 2011 at 11:23 AM, Jim Silverton wrote: > Hi, > Can som

Re: [R] Removing rows of zeros from a matrix

2011-06-02 Thread Jim Silverton
Hi, Can someone tell me how to remove rows of zeros from a matrix? For example if I have the following matrix, 0 0 0 1 2 8 0 0 4 56 I should end up with 0 1 2 8 4 56 -- Thanks, Jim. [[alternative HTML version deleted]] __ R-help@r-project.or