In this post I will attempt to have a go with animation using the R programming language. It seems like an arduous task no doubt, given the toolkit our output will be very simple yet still data sciency in spirit.
Here I will be utilizing the built in PlantGrowth data set within the R library.
The PlantGrowth data set is a collection of data from an experiment to compare yields (as measured by dried weight of plants) obtained under a control and two different treatment conditions. The levels of group are ‘ctrl’, ‘trt1’, and ‘trt2’. I hope this summary helps! 😊
And without further ado. Some code:
library(ggplot2)
library(gganimate)
library(gifski)
library(ggdark)
data("PlantGrowth")
p <- ggplot(PlantGrowth, aes(x=group, y=weight)) +
geom_boxplot(aes(color = group)) +
scale_color_manual(values = c("red", "blue", "green")) +
dark_theme_dark() +
transition_manual(group) +
labs(title = 'Treatment: {Fertilizer Effect On Plant Growth}')
animate(p, renderer = gifski_renderer())
anim_save("temp.gif", animation = last_animation(), path = "C:/Users/Nunya/Business")
And the output.