Re: [R] help with table partition

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Fri 16 Jun 2006 - 00:34:39 EST


Hi

maybe ?split and ?t is what you want

mat<-matrix(rnorm(1000), 100,10)

mat.s<-split(data.frame(mat), rep(1:5, each=20)) #splits mat to list with 5 eqal submatrices

lapply(mat.s,t)
# transpose matrices in list

gives you a list of transposed tables, which is probably better than separate tables. Just change rep(1:5,each=20) to rep (1:170, each=366).

or
a quicker one without data frame

mat <- matrix(rnorm(62220*73), 62220,73)

dim(mat) <- c(366,73,170)
mat.i <- array(0,dim=c(73,366,170))
for (i in 1:170) mat[ , , i] <- t(mat[ , , i])

HTH
Petr

On 15 Jun 2006 at 9:38, Wong, Kim wrote:

Date sent:      	Thu, 15 Jun 2006 09:38:29 -0400
From:           	"Wong, Kim" <kwong@nymex.com>
To:             	<r-help@stat.math.ethz.ch>
Subject:        	[R] help with table partition

> Hi,
>
>
>
> I have a test_table where the dim is 62220 by 73 (row by col)
>
>
>
> I would like to partition the rows into 170 equal parts (170 tables
> where each is of dim 366 by 73), and rearrange them horizontally. The
> source codes I have:
>
>
>
> for (i in 1:170) {
>
> c = cbind(c,test_table[(367*i+1):(367*(i+1)),2:73]);
>
> }
>
>
>
> Unfortunately, using for loop and cbind for a table of this size
> causes long running time. What is the most efficient way to get the
> table that I want?
>
>
>
> Thanks for any help.
>
> K.
>
>
>
>
> -----------------------------------------
> CONFIDENTIALITY NOTICE: This message and any attachments
> rel...{{dropped}}
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal@precheza.cz



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jun 16 02:16:46 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 16 Jun 2006 - 04:12:58 EST.

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