Open ramnathv opened 10 years ago
Here is another illustration of something that could be fun
library(rblocks)
block = make_block(5, 5, type = 'matrix')
animation::saveGIF({
i = 1
while (i <= 5){
block[i,1:i] = 'red'
block[1:i,i] = 'red'
display(block)
block = make_block(5, 5, type = 'matrix')
i = i + 1
}
})
Here is a slightly modified version of the code, which will display the gif directly in RStudio
for (i in 1:5){
dev.hold()
block[i, i] = 'red'
display(block)
ani.pause()
}
How do you embed the animation?
It is a gif file. So treat it like an image.
Thanks! This is very cool.
@yihui Thanks to your animation package, this was really easy!
Conway's Game of Life (Codes - rBlocks_test_03.R) (Original R Codes for the G.O.L.)
Thanks @ramnathv and @yihui !!
Here is a cool application using the
animation
package by @yihui to visualize how loops work, along with rblocks.