generated from jtr13/cctemplate
-
Notifications
You must be signed in to change notification settings - Fork 139
/
animate_time_series.Rmd
91 lines (63 loc) · 3.27 KB
/
animate_time_series.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Animate Time Series : the `goyav` package
Antonin Vidon
```{r}
# install.packages("devtools")
# library(devtools)
# install_github("AntoninVidon/goyav")
library(goyav) # must be installed from source
# install.packages("gapminder")
library(gapminder)
```
## Motivation
One of the main drawbacks of the IDE RStudio is the lack of real interaction between the user and the plots generated from raw data. Even for simple plots, the user often has to go through a lot of documentation and/or look at heavy web located tutorials.
We build a shiny-app based interface on which the user tunes dynamically the plot he wants to build by offering choices among true candidates for each parameter (no error possible). We choose to focus on “animated” plots. These are dynamic plots generated from temporal data. This type of plot is especially tedious to build in a “hard-code” way with the `gganimate` package. We add some interesting features such as *filter on a factor*, *choose x,y and temporal range*, *change any/both of the scales to log-scales*, *modify the duration of the animation*, … These are common operations that a meticulous user might want to perform in order to draw impactful plots.
## Features
`goyav` is a shiny App meant to generate GIF animations from tabular temporal data. All customization of the animated plots is done in an interactive window.
The dashboard of the application looks like this :
```{r, echo=FALSE}
knitr::include_graphics("resources/animate_time_series/dashboard.PNG")
```
The user is able to navigate into two tabs : "Animate" and "Advanced animate", the latter offering a wider range of customization.
From the *Animate* tab, you may choose the following :
- X variable (numeric);
- Y variable (numeric);
- size variable (numeric);
- color variable (optional, factor);
- temporal variable (numeric);
- choose if you want to apply a log-scale to either X, Y or X and Y (optional).
From the *Advanced animated* tab, you may choose the following :
- X variable (numeric);
- Y variable (numeric);
- size variable (numeric);
- color variable (optional, factor);
- temporal variable (numeric);
- choose if you want to apply a log-scale to either X, Y or X and Y (optional);
- X range;
- Y range;
- temporal range;
- Animation duration (s);
- Factor levels to include (optional, among color variable levels).
## Demonstration
In order to better show the use of the package, we will use the `gapminder` dataset from the `gapminder` package.
```{r}
# display first rows of dataset
knitr::kable(head(gapminder))
```
In order to be able to create any GIF, your dataframe should have candidate columns for the following variables: X, Y, size and temporal. Therefore, *calling the `goyav` function on a dataframe with less than 4 numeric variables will return an error*.
```{r, error=TRUE}
# try to call the `goyav` function on the first 3 columns of the `gapminder` dataset
goyav(gapminder[,1:3])
```
Let's now call `goyav` on the whole dataset :
```{r eval=FALSE}
# call `goyav` on `gapminder`
goyav(gapminder)
```
### View from the *Animate* tab
```{r, echo=FALSE}
knitr::include_graphics("resources/animate_time_series/Animate.gif")
```
### View from the *Advanced animate* tab
```{r, echo=FALSE}
knitr::include_graphics("resources/animate_time_series/AdvancedAnimate.gif")
```