transposeBigData | R Documentation |
This transpose command partitions a big matrix (or data frame) into blocks and applies the t() function to each block separately.
transposeBigData(x, blocksize = 20000)
x |
a matrix or data frame |
blocksize |
a positive integer larger than 1, which determines the block size. Default is 20k. |
Assume you have a very large matrix with say 500k columns. In this case, the standard transpose function of
R t()
can take a long time. Solution: Split the original matrix into sub-matrices by dividing the
columns into blocks. Next apply t()
to each sub-matrix. The same holds if the large matrix contains
a large number of rows. The function transposeBigData
automatically checks whether the large matrix
contains more rows or more columns. If the number of columns is larger than or equal to the number of rows
then the block wise splitting will be applied to columns otherwise to the rows.
A matrix or data frame (depending on the input x
) which is the transpose of x
.
This function can be considered a wrapper of t()
Steve Horvath, UCLA
Any linear algebra book will explain the transpose.
The standard function t
.
x=data.frame(matrix(1:10000,nrow=4,ncol=2500))
dimnames(x)[[2]]=paste("Y",1:2500,sep="")
xTranspose=transposeBigData(x)
x[1:4,1:4]
xTranspose[1:4,1:4]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.