Description Usage Arguments Value Examples
percolate
1 2 | ## S3 method for class 'board'
percolate(start_board)
|
start_board |
a board object to be percolated |
a list containing the field result: a T/F indicating whether or not the board percolated and result_board: a board object after the percolation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | m = board(generate_board_mat(n = 100, p = 0.4)); plot(percolate(m)$result_board)
mat_example_list <- list(matrix(c(1,1,1,1,0,
0,0,0,1,0,
1,1,1,1,0,
0,1,0,0,0,
0,1,1,1,1), 5, 5),
matrix(c(1,1,1,1,0,
0,0,0,1,0,
0,1,1,1,0,
0,1,0,0,0,
0,1,1,1,1), 5, 5),
matrix(c(1,1,1,1,0,
0,0,0,1,0,
0,1,1,0,0,
0,1,0,0,0,
0,1,1,1,1), 5, 5))
mat_boards = lapply(mat_example_list, FUN = board)
mat_perc_boards = lapply(mat_boards, FUN = function(b)(percolate(b)$result_board))
all = c(mat_boards, mat_perc_boards)
mat_plots = lapply(all, FUN = plot)
library(gridExtra)
grid.arrange(grobs = mat_plots, ncol = 3, nrow = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.