expand_aggregated_data: Expand aggregated data Several datasets for the Bradley-Terry...

Description Usage Arguments Value Examples

View source: R/bpc_data_transformation.R

Description

Expand aggregated data Several datasets for the Bradley-Terry Model aggregate the number of wins for each player in a different column. The models we provide are intended to be used in a long format. A single result for each contest. This function expands datasets that have aggregated data into this long format.

Usage

1
expand_aggregated_data(d, player0, player1, wins0, wins1, keep)

Arguments

d

a data frame

player0

string with column name of player0

player1

string with column name of player1

wins0

string with column name of the number of wins of player 0

wins1

string with column name of the number of wins of player 1

keep

an array of strings with the name of columns we want to keep in the new data frame (and repeat in every expanded row)

Value

a data frame with the expanded dataset. It will have the columns player1, player0, y, the keep columns, and a rowid column (to make each row unique)

Examples

1
2
3
4
#Creating a simple data frame with only one row to illustrate how the function works
df1 <- tibble::tribble(~player0, ~player1, ~wins0, ~wins1,~cluster, 'A','B',4, 3, 'c1')
df2 <- expand_aggregated_data(df1,'player0', 'player1', 'wins0', 'wins1', keep=c('cluster'))
print(df2)

bpcs documentation built on Dec. 15, 2020, 5:23 p.m.