Little useless-useful R functions – Animating datasets
This article is originally published at https://tomaztsql.wordpress.com
I firmly believe that animation and transition between different data states can give end-users much better insights and understanding of the data, than a single table with data points or correlation metrics.
With help of ggplot, gganimate, you can quickly create an animation based on your needs. This is a simple IRIS dataset example.
And the useless function with the transitions between the data points:
ggplot(iris, aes(factor(Species), Sepal.Length, colour = Species)) +
geom_boxplot(show.legend = FALSE) +
labs(title = 'Petal width: {as.numeric(format(round(frame_time, 2), nsmall = 2))}', x= 'Iris species', y = 'Sepal Length') +
# transition_time(as.numeric(Petal.Width)) +
transition_time(as.numeric(Petal.Width)) +
ease_aes('sine-in-out') +
enter_fade() +
theme_hc()
As always, code is available on the Github in the same Useless_R_function repository. Check Github for future updates.
Happy R-coding and stay healthy!“
Thanks for visiting r-craft.org
This article is originally published at https://tomaztsql.wordpress.com
Please visit source website for post related comments.