Title: | Visualizing Changes in Performance Measures and Demographic Affiliations using Animation |
---|---|
Description: | Create an interactive visualization to be used for communication purposes. Providing the function for preparing, plotting, and animating the data. Krisanat Anukarnsakulchularp (2023) <https://github.com/KrisanatA/animbook-journal> |
Authors: | Krisanat Anukarnsakulchularp [aut, cre, cph]
|
Maintainer: | Krisanat Anukarnsakulchularp <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0.9000 |
Built: | 2025-02-12 04:41:41 UTC |
Source: | https://github.com/krisanata/animbook |
The aes dataset contains the answers to the surveys that were done in 2019 for the election. This dataset only includes the id, year, party, and gender from the full survey data. The year column comes from the transformations of two different questions to see whether the voter voted for the same party in 2016 and 2019 or not, and if not, who did they vote for before?
aeles
aeles
A data frame with 1,468 rows and 4 variables
The id of the respondent
Year
Party that the respondent votes for in the House of Representatives
Gender of the respondent
This dataset is from the following; Australian Election Study https://dataverse.ada.edu.au/file.xhtml?fileId=18013&version=3.0
This function will modify the ggplot object before the user can pass it to the rendering of choice.
anim_animate(plot)
anim_animate(plot)
plot |
ggplot object |
A gganimate object if the rendering is gganimate or a ggplot object if the rendering is plotly.
animbook <- anim_prep(data = osiris, id = ID, values = sales, time = year, group = japan) plot <- wallaby_plot(animbook) animate <- anim_animate(plot) plotly::ggplotly(animate)
animbook <- anim_prep(data = osiris, id = ID, values = sales, time = year, group = japan) plot <- wallaby_plot(animbook) animate <- anim_animate(plot) plotly::ggplotly(animate)
This function transformed the numerical data into the categorized format by grouping data and scaling values.
anim_prep( data, id = NULL, values = NULL, time = NULL, group = NULL, ncat = 5L, breaks = NULL, label = NULL, group_scaling = NULL, scaling = "rank" )
anim_prep( data, id = NULL, values = NULL, time = NULL, group = NULL, ncat = 5L, breaks = NULL, label = NULL, group_scaling = NULL, scaling = "rank" )
data |
A data frame contained the numerical values. |
id |
The column name that represents the identifiers variable. |
values |
The column name contains the numeric values. |
time |
The column name that represents the time variable. |
group |
The column name that represents the distinguished group between the values. |
ncat |
The number of categories to be created for scaling values. |
breaks |
A vector of breaks for creating bins. |
label |
A vector of labels to represent the qtile. |
group_scaling |
The column name that will be used for grouping the variable before scaling. |
scaling |
The scaling method to be used; "rank" or "absolute". |
The function takes the input data and performs several operations to transformed it into categorized format. It is done by grouping data, scales values, and assigned the qtile.
A categorized data.
# rank scaling anim_prep(data = osiris, id = ID, values = sales, time = year) # group_rank scaling anim_prep(data = osiris, id = ID, values = sales, time = year, group_scaling = country) # absolute scaling anim_prep(data = osiris, id = ID, values = sales, time = year, scaling = "absolute") # group_absolute scaling anim_prep(data = osiris, id = ID, values = sales, time = year, group_scaling = country, scaling = "absolute")
# rank scaling anim_prep(data = osiris, id = ID, values = sales, time = year) # group_rank scaling anim_prep(data = osiris, id = ID, values = sales, time = year, group_scaling = country) # absolute scaling anim_prep(data = osiris, id = ID, values = sales, time = year, scaling = "absolute") # group_absolute scaling anim_prep(data = osiris, id = ID, values = sales, time = year, group_scaling = country, scaling = "absolute")
This function transformed the category data in the categorized format by ordering the values.
anim_prep_cat( data, id = NULL, values = NULL, time = NULL, group = NULL, order = NULL, label = NULL )
anim_prep_cat( data, id = NULL, values = NULL, time = NULL, group = NULL, order = NULL, label = NULL )
data |
A data frame contained the category values. |
id |
The column name that represents the identifiers variable. |
values |
The column name contains the category values. |
time |
The column name that represents the time variable. |
group |
The column name that represents the distinguished group between the values. |
order |
A vector of order for sorting the category values. |
label |
A vector of labels to represent the qtile. |
The function takes the input data, ordering the values, and assigning the variable names.
A categorized data.
anim_prep_cat(data = aeles, id = id, values = party, time = year)
anim_prep_cat(data = aeles, id = id, values = party, time = year)
This data has changed from category A to E between two-time points.
cat_change
cat_change
A data frame with 400 rows and 4 variables
The id of the organisation
time
Either X or Y
Quantile group for the two times
d <- anim_prep_cat(cat_change, id = id, values = qnt, time = time, group = gp) d_p <- wallaby_plot(d, height = 1) d_p_anim <- anim_animate(d_p)
d <- anim_prep_cat(cat_change, id = id, values = qnt, time = time, group = gp) d_p <- wallaby_plot(d, height = 1) d_p_anim <- anim_animate(d_p)
This data contained the numerical values for each observation.
dbl_change
dbl_change
A data frame with 400 rows and 4 variables
The id of the organisation
time
Either X or Y
Numerical values represent sales
d <- anim_prep(dbl_change, id = id, values = values, time = time, group = gp) d_p <- wallaby_plot(d, height = 1) d_p_anim <- anim_animate(d_p)
d <- anim_prep(dbl_change, id = id, values = values, time = time, group = gp) d_p <- wallaby_plot(d, height = 1) d_p_anim <- anim_animate(d_p)
This function takes in the data which has been prepared by either anim_prep()
or anim_prep_cat()
and
return the ggplot object. The user can still modify the plot the same as normal using the ggplot2 function.
funnel_web_plot(data, group_palette = NULL, ...)
funnel_web_plot(data, group_palette = NULL, ...)
data |
The animbook object returned from the prep function. |
group_palette |
The vector of the palette used by the function to supply the color to each group. |
... |
Additional arguments for customization. See details for more information. |
This function takes prepared data and generates a ggplot object. The funnel web plot is the plot that shows the line facetted plot showing the pattern between time period. The line jitter can be controlled using additional arguments such as height and width to control the appearance. For the shading area, the alpha argument can be used.
Return a ggplot object.
animbook <- anim_prep(data = osiris, id = ID, values = sales, time = year, group = japan) funnel_web_plot(animbook)
animbook <- anim_prep(data = osiris, id = ID, values = sales, time = year, group = japan) funnel_web_plot(animbook)
This function takes in the data which has been prepared by the anim_prep()
or anim_prep_cat()
and return the ggplot object. The user can still modify
the plot as usual.
kangaroo_plot( data, group_palette = NULL, shade_palette = NULL, rendering = "gganimate", time_dependent = FALSE, ... )
kangaroo_plot( data, group_palette = NULL, shade_palette = NULL, rendering = "gganimate", time_dependent = FALSE, ... )
data |
The categorized data. |
group_palette |
The vector of the palette used by the function to supply the color of each group. |
shade_palette |
The vector of the palette used by the function to supply the color to the shaded area. |
rendering |
The choice of method used to create and display the plot, either gganimate or plotly. |
time_dependent |
Logical. Should the visualization be time-dependent? The default is FALSE. |
... |
Additional arguments for customization. See details for more information. |
This function takes categorized data and generates a ggplot object. The kangaroo plot is the plot that shows the movement between groups over time. The point position and point size in the shaded area can be controlled using additional arguments such as height, width, and size. For the shading area, the alpha argument can be used.
Return a ggplot object.
example <- anim_prep(data = dbl_change, id = id, values = values, time = time, group = gp) kangaroo_plot(example)
example <- anim_prep(data = dbl_change, id = id, values = values, time = time, group = gp) kangaroo_plot(example)
The Osiris dataset contains information on listed and major unlisted/delisted companies across the world from 2006 to 2018. This dataset only includes the year, ID, country, sales, and japan variables from the full Osiris dataset to give the user an example of the dataset format.
osiris
osiris
A data frame with 10,270 rows and 5 variables
Year
BvD(Bureau van Dijk) ID
Address of incorp. - Country
Sales
Whether the firm is from Japan or not
This dataset is from the following; Bureau van Dijk https://www.bvdinfo.com/en-gb/our-products/data/international/osiris.
This function takes in the data which has been prepared by the anim_prep()
or anim_prep_cat()
and return the ggplot object. The user can still modify
the plot as usual.
wallaby_plot( data, group_palette = NULL, shade_palette = NULL, rendering = "gganimate", time_dependent = FALSE, subset = "top", relation = "one_many", total_point = NULL, x_lab = NULL, ... )
wallaby_plot( data, group_palette = NULL, shade_palette = NULL, rendering = "gganimate", time_dependent = FALSE, subset = "top", relation = "one_many", total_point = NULL, x_lab = NULL, ... )
data |
The categorized data. |
group_palette |
The vector of the palette used by the function to supply the color of each group. |
shade_palette |
The vector of the palette used by the function to supply the color of each shaded area. |
rendering |
The choice of method used to create and display the plot, either gganimate or plotly. |
time_dependent |
Logical. Should the visualization be time-dependent? The default is FALSE. |
subset |
A character string specifying the variable used for subsetting the data. The "top" and "bottom" strings can also be used in this argument. |
relation |
The choice of relationship for the values to display on the plot, either "one_many" or "many_one." |
total_point |
The number of points the users want for the wallaby plot. The default is NULL, where the number of the point is equal to the original number of points. |
x_lab |
The label for the x-axis. |
... |
Additional arguments for customization. See details for more information. |
This function takes categorized data and generates a ggplot object. The wallaby plot is the plot that shows the movement of the subset data between the start and end of the observable period. The point position and point size in the shaded area can be controlled using additional arguments such as height, width, and size. For the shading area, the alpha argument can be used.
Return a ggplot object.
animbook <- anim_prep(data = osiris, id = ID, values = sales, time = year, group = japan) wallaby_plot(animbook)
animbook <- anim_prep(data = osiris, id = ID, values = sales, time = year, group = japan) wallaby_plot(animbook)