Description Usage Arguments Value Author(s) See Also Examples
View source: R/matrix_to_blocks.r
Split a matrix into a list of blocks (either by rows or by columns)
1 | matrix_to_blocks(Matrix, blocks, byrow = TRUE)
|
Matrix |
a matrix to split |
blocks |
either a list or a vector indicating the
blocks. If |
byrow |
logical. If |
A list of matrices
Gaston Sanchez
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # matrix with 10 rows and 7 columns
M = matrix(rnorm(70), 10, 7)
# row blocks
row_sets = list(1:3, 4:5, 6:10)
# split matrix by rows
matrix_to_blocks(M, row_sets)
# column blocks
col_sets = c(3, 4)
# split matrix by rows
matrix_to_blocks(M, col_sets, byrow=FALSE)
|
Attaching package: 'turner'
The following object is masked from 'package:base':
lengths
[[1]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] -0.5472893 -0.5902474 0.2471662 1.4983757 -0.6286968 1.685142 1.9044569
[2,] 0.2726798 -0.6452849 1.1895195 0.5676669 -1.0244267 -2.112856 -0.3411200
[3,] -0.1496725 1.2772919 2.0255955 1.3402460 -0.5257598 1.780134 0.3090321
[[2]]
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] -0.2777342 -0.9177540 1.721689 0.4761462 0.6535606 -0.5722103 1.4749489
[2,] -0.5424928 -0.3411447 1.246191 -1.1016969 0.1227002 0.7753965 -0.5576772
[[3]]
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] -1.7790559 -0.7345397 -0.3675565 -0.8344598 1.7496380 -1.9401020
[2,] 2.1104226 -0.5628160 -0.4601471 0.8364645 -0.1854451 -0.2970309
[3,] 0.8395387 0.4903054 1.7758980 -1.4065472 -0.8955588 0.3294168
[4,] -0.8539439 -0.6033897 -0.6575203 0.7529293 1.0040618 1.0985585
[5,] -1.0910718 -1.2841380 -1.2995096 1.0075262 -0.0390433 0.4508892
[,7]
[1,] -0.913232638
[2,] 0.641387028
[3,] -0.048036141
[4,] -0.009841404
[5,] -0.042836974
[[1]]
[,1] [,2] [,3]
[1,] -0.5472893 -0.5902474 0.2471662
[2,] 0.2726798 -0.6452849 1.1895195
[3,] -0.1496725 1.2772919 2.0255955
[4,] -0.2777342 -0.9177540 1.7216887
[5,] -0.5424928 -0.3411447 1.2461906
[6,] -1.7790559 -0.7345397 -0.3675565
[7,] 2.1104226 -0.5628160 -0.4601471
[8,] 0.8395387 0.4903054 1.7758980
[9,] -0.8539439 -0.6033897 -0.6575203
[10,] -1.0910718 -1.2841380 -1.2995096
[[2]]
[,1] [,2] [,3] [,4]
[1,] 1.4983757 -0.6286968 1.6851420 1.904456937
[2,] 0.5676669 -1.0244267 -2.1128559 -0.341120014
[3,] 1.3402460 -0.5257598 1.7801340 0.309032087
[4,] 0.4761462 0.6535606 -0.5722103 1.474948948
[5,] -1.1016969 0.1227002 0.7753965 -0.557677250
[6,] -0.8344598 1.7496380 -1.9401020 -0.913232638
[7,] 0.8364645 -0.1854451 -0.2970309 0.641387028
[8,] -1.4065472 -0.8955588 0.3294168 -0.048036141
[9,] 0.7529293 1.0040618 1.0985585 -0.009841404
[10,] 1.0075262 -0.0390433 0.4508892 -0.042836974
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.