powered by
Applies round_matrix() to equally-sized blocks that partition the matrix either vertically or horizontally.
round_matrix()
round_by_blocks(Y, layout, L, digits = 0, MARGIN_BLOCK = 0)
The rounded matrix.
Matrix.
The blocks are distributed: 1 horizontally, 2 vertically.
Number of lines that a block encompasses.
Number of decimal places to be rounded to.
For each block
0 Preserves the rounded colSums and rowSums.
1 Preserves the rounded rowSums independently of each other.
2 Preserves the rounded colSums independently of each other.
set.seed(10) Y <- (rnorm(32)*10) |> matrix(ncol = 2) |> round(3) X <- round_by_blocks(Y, 2, 4) U <- Y[5:8,] |> round_matrix() X[5:8,] - U
Run the code above in your browser using DataLab