[R] help with table partition
Petr Pikal
petr.pikal at precheza.cz
Thu Jun 15 16:34:39 CEST 2006
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 at nymex.com>
To: <r-help at 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 at 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 at precheza.cz
More information about the R-help
mailing list