c_array_as_df: Convert C matrix array to data.frame

Description Usage Arguments Value Examples

View source: R/c_array_as_df.R

Description

Converts the C history array from the mELO output to a data.frame. Useful for plotting diagnostics.

Usage

1
c_array_as_df(c_mat_array)

Arguments

c_mat_array

The history of C matrix values for a mELO rating model.

Value

A data.frame.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# rock paper scissors fire water model
rpsfw_model <- mELO(rpsfw_df, k=2)
c_mat_df <- c_array_as_df(rpsfw_model$c_mat_history)
head(c_mat_df)

# Plot the evolution of C vectors for each throw
# Make data a bit 'tidyer'
tidy_c_mat_df <- tidyr::gather(
    c_mat_df,
    key = "C",
    value = "value",
    -time, -Player
    )
ggplot2::ggplot(tidy_c_mat_df, ggplot2::aes(x=time,y=value,colour=C)) +
    ggplot2::geom_line(size=1.25) +
    ggplot2::facet_wrap(~Player)

dclaz/mELO documentation built on May 17, 2021, 2:27 a.m.