[R] Column Extraction from matrix

David L Carlson dcarlson at tamu.edu
Thu Aug 16 17:05:28 CEST 2012


You could also use a 3d array instead of a list:

> m <- matrix(1:400, ncol=100, byrow=TRUE)
> a <- array(m, dim=c(2, 2, 100), dimnames=list(row=c(1, 2), 
      col=c(1, 2), tbl=c(paste0("a", 1:100))))

> a[,,1] # First table by index
   col
row   1   2
  1   1 201
  2 101 301
> a[,,"a1"] # First table by name
   col
row   1   2
  1   1 201
  2 101 301
>

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of bantex
> Sent: Thursday, August 16, 2012 7:28 AM
> To: r-help at r-project.org
> Subject: Re: [R] Column Extraction from matrix
> 
> Thanks guys for the help. I finally know what to do know :)
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Column-
> Extraction-from-matrix-tp4640465p4640482.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