Created
March 4, 2019 03:04
-
-
Save muschellij2/a788c5c24df32052216e82d314f6c8da to your computer and use it in GitHub Desktop.
Take an R Script and make it into a gif.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rsciinema) | |
input = paste0("library(magrittr); # a comment is a gra", backspace(), "eat thing to do", | |
"\niris %>% \n dplyr::group_by(Species) %>%\n ", | |
"dplyr::summarise_all(mean) \n # a new line") | |
data = asciicast( input ) | |
json = rsciinema::json_asciicast(data) | |
tfile = tempfile(fileext = ".json") | |
writeLines(json, con = tfile) | |
gif = tempfile(fileext = ".gif") | |
cmd = paste("asciicast2gif", tfile, gif) | |
system(cmd) | |
svg = tempfile(fileext = ".svg") | |
cmd = paste("cat", tfile, "|", "svg-term --out ", svg) | |
system(cmd) | |
input = paste0("library(magrittr); # a comment is a gra", backspace(), "eat thing to do", | |
"\niris %>% \n dplyr::group_by(Species) %>%\n ", | |
"dplyr::summarise_all(mean) \n # a new line") | |
data = asciicast( input ) | |
# extend time to look at the data | |
ind = grep("A tibble", data$text) | |
data$time[ind + 1] = data$time[ind + 1] + 5 | |
json = rsciinema::json_asciicast(data) | |
tfile = tempfile(fileext = ".json") | |
writeLines(json, con = tfile) | |
svg = tempfile(fileext = ".svg") | |
cmd = paste("cat", tfile, "|", "svg-term --out ", svg) | |
system(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment