This function transformed the numerical data into the categorized format by grouping data and scaling values.
Usage
anim_prep(
data,
id = NULL,
values = NULL,
time = NULL,
group = NULL,
ncat = 5L,
breaks = NULL,
label = NULL,
group_scaling = NULL,
scaling = "rank"
)
Arguments
- 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".
Details
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.
Examples
# rank scaling
anim_prep(data = osiris, id = ID, values = sales, time = year)
#> # A tibble: 10,270 × 4
#> id time qtile label
#> <fct> <int> <dbl> <chr>
#> 1 AE30008GU 2006 1 1
#> 2 AT9110050653 2006 3 3
#> 3 AU001150849 2006 5 5
#> 4 AU004085330 2006 1 1
#> 5 AU006624228 2006 2 2
#> 6 AU008720223 2006 5 5
#> 7 AU009066648 2006 5 5
#> 8 AU009134114 2006 3 3
#> 9 AU009213754 2006 4 4
#> 10 AU009219809 2006 2 2
#> # ℹ 10,260 more rows
# group_rank scaling
anim_prep(data = osiris, id = ID, values = sales, time = year,
group_scaling = country)
#> # A tibble: 10,270 × 5
#> id time qtile label group_scaling
#> <fct> <int> <dbl> <chr> <fct>
#> 1 AE30008GU 2006 0 0 AE
#> 2 AT9110050653 2006 0 0 AT
#> 3 AU001150849 2006 4 4 AU
#> 4 AU004085330 2006 1 1 AU
#> 5 AU006624228 2006 1 1 AU
#> 6 AU008720223 2006 4 4 AU
#> 7 AU009066648 2006 5 5 AU
#> 8 AU009134114 2006 2 2 AU
#> 9 AU009213754 2006 3 3 AU
#> 10 AU009219809 2006 2 2 AU
#> # ℹ 10,260 more rows
# absolute scaling
anim_prep(data = osiris, id = ID, values = sales, time = year,
scaling = "absolute")
#> # A tibble: 10,270 × 4
#> id time qtile label
#> <fct> <int> <dbl> <chr>
#> 1 AE30008GU 2006 5 5
#> 2 AT9110050653 2006 5 5
#> 3 AU001150849 2006 5 5
#> 4 AU004085330 2006 5 5
#> 5 AU006624228 2006 5 5
#> 6 AU008720223 2006 5 5
#> 7 AU009066648 2006 5 5
#> 8 AU009134114 2006 5 5
#> 9 AU009213754 2006 5 5
#> 10 AU009219809 2006 5 5
#> # ℹ 10,260 more rows
# group_absolute scaling
anim_prep(data = osiris, id = ID, values = sales, time = year,
group_scaling = country, scaling = "absolute")
#> # A tibble: 10,270 × 5
#> id time qtile label group_scaling
#> <fct> <int> <dbl> <chr> <fct>
#> 1 AE30008GU 2006 4 4 AE
#> 2 AT9110050653 2006 5 5 AT
#> 3 AU001150849 2006 5 5 AU
#> 4 AU004085330 2006 5 5 AU
#> 5 AU006624228 2006 5 5 AU
#> 6 AU008720223 2006 5 5 AU
#> 7 AU009066648 2006 5 5 AU
#> 8 AU009134114 2006 5 5 AU
#> 9 AU009213754 2006 5 5 AU
#> 10 AU009219809 2006 5 5 AU
#> # ℹ 10,260 more rows