knitr::opts_chunk$set(echo = TRUE)
library(tidyverse) library(htmltools) library(knitr) library(codehover)
dir.create("./IMG/")
g <- ggplot2::ggplot() + geom_point(data = cars, aes(x = speed, y = dist)) ggplot2::ggsave("./IMG/1.png", width = 4, height = 3) g <- g + aes(color = "red") ggplot2::ggsave("./IMG/2.png", width = 4, height = 3) g <- g + scale_y_continuous(limits = c(0,100)) ggplot2::ggsave("./IMG/3.png", width = 4, height = 3) g <- g + labs(title = "A ggplot fot the rest of us") ggplot2::ggsave("./IMG/4.png", width = 4, height = 3) g <- g + labs(subtitle = "Testing a way of explicit showing the R workflow") ggplot2::ggsave("./IMG/5.png", width = 4, height = 3) g <- g + theme_bw() ggplot2::ggsave("./IMG/6.png", width = 4, height = 3)
result <- ch_int(type = "incremental") %>% ch_row(text = "ggplot() + <br> <tab1> geom_point(data = cars, </tab1> <br> <tab2> aes(x = speed, </tab2> <br> <tab2> y = dist, </tab2>", img ="./IMG/1.png") %>% ch_row(text = "<tab2> color = 'red')) + </tab2>", img ="./IMG/2.png") %>% ch_row(text = "<tab1> scale_y_continuous(limits = c(0,100)) + </tab1>", img ="./IMG/3.png") %>% ch_row(text = "<tab1> labs(title = 'A ggplot fot the rest of us', </tab1>", img ="./IMG/4.png") %>% ch_row(text = "<tab2> subtitle = 'Testing a way of explicit showing the R workflow') + </tab2>", img ="./IMG/5.png") %>% ch_row(text = "<tab1> theme_bw()</tab1> ", img ="./IMG/6.png") %>% ch_out(img = "./IMG/1.png")
htmltools::HTML(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.