[R] R matrix help

R. Michael Weylandt michael.weylandt at gmail.com
Thu Jun 14 17:05:19 CEST 2012


But there are multiple shapes for matrices with 12 elements -- how did
you get 3x4 ? You also could have had 1x12, 2x6, 3x4, 4x3, 6x2,12x1

If you have an R object, you can use dim() on it. [Or perhaps slightly
more robustly, NCOL() and NROW()]

Michael

On Thu, Jun 14, 2012 at 7:51 AM, karthicklakshman
<karthick.lakshman at gmail.com> wrote:
> Dear R experts,
>
> I am interested in getting the dimensions for the matrix dynamically, based
> on the the number of elements in a matrix for example. if the number is 12,
> I should get dim= 3X4,  if it is 20, dim=5X4.
> please help me do this.
>
> Thank you
> Regards
> karthick
>
> --
> View this message in context: http://r.789695.n4.nabble.com/R-matrix-help-tp4633372.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.



More information about the R-help mailing list