# Re: [R] sub-matrix block size

From: Peter Alspach <Peter.Alspach_at_plantandfood.co.nz>
Date: Wed, 27 Apr 2011 15:00:36 +1200

Tena koe Santosh

It is not clear to me precisely what your blocking rules are (e.g., where should matrix[4,4] go, is matrix[5:7,5:7] to be considered as a different block to matrix[8:10,8:10]). Also, what happens if there is an isolated 1 (e.g., in location matrix[9,6])? However, I imagine something could be achieved with judicious use of diag() and rle().

HTH .... Peter Alspach

> -----Original Message-----
> From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-
> project.org] On Behalf Of Santosh
> Sent: Wednesday, 27 April 2011 12:14 p.m.
> To: r-help
> Subject: [R] sub-matrix block size
>
> Dear Rxperts
>
> Below is a small vector of values of zeros and non-zeros... was
> wondering if
> there is an efficient way to get the block sizes of submatrices of a
> big
> matrix similar to the one shown below? diagonal elements can be zero
> too.
> Rows with only a diagonal element may be considered as a unit block
> size.
>
> c(1,0,0,0,0,0,0,0,0,0,0,
> 1,1,0,0,0,0,0,0,0,0,0,
> 0,0,1,0,0,0,0,0,0,0,0,
> 0,0,0,0,0,0,0,0,0,0,0,
> 0,0,0,0,1,0,0,0,0,0,0,
> 0,0,0,0,1,1,0,0,0,0,0,
> 0,0,0,0,1,1,1,0,0,0,0,
> 0,0,0,0,0,0,0,1,0,0,0,
> 0,0,0,0,0,0,0,1,1,0,0,
> 0,0,0,0,0,0,0,1,1,1,0,
> 0,0,0,0,0,0,0,0,0,0,0)
>
> Thanks much!
> Santosh
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

The contents of this e-mail are confidential and may be subject to legal privilege.  If you are not the intended recipient you must not use, disseminate, distribute or  reproduce all or any part of this e-mail or attachments. If you have received this  e-mail in error, please notify the sender and delete all material pertaining to this  e-mail. Any opinion or views expressed in this e-mail are those of the individual  sender and may not represent those of The New Zealand Institute for Plant and  Food Research Limited.

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. Received on Wed 27 Apr 2011 - 03:11:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 27 Apr 2011 - 03:40:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.