Enriches and standardizes raw game data with user-perspective columns, readable timestamps, and opponent details.
Arguments
- data
Raw game tibble returned by
lic_games_user()orlic_game().- username
Target username to calculate user-centric perspective. If
NULL, user-centric columns (user_color,user_result,win) will not be computed.
Value
A tidy tibble::tibble with standardized column names and types.
Details
This is an offline data transformation function (no API network request).
It standardizes raw data returned by lic_games_user() or lic_game().
Examples
sample_raw <- tibble::tibble(
id = "demo123",
createdAt = 1730000000000,
players.white.user.name = "h8gi",
players.black.user.name = "opponent",
players.white.rating = 2100L,
players.black.rating = 2050L,
winner = "white"
)
lic_tidy_games(sample_raw, username = "h8gi")
#> # A tibble: 1 × 17
#> id createdAt players.white.user.name players.black.user.name
#> <chr> <dbl> <chr> <chr>
#> 1 demo123 1730000000000 h8gi opponent
#> # ℹ 13 more variables: players.white.rating <int>, players.black.rating <int>,
#> # winner <chr>, created_at <dttm>, white_name <chr>, black_name <chr>,
#> # user_color <chr>, user_result <chr>, win <lgl>, user_rating <int>,
#> # opponent_rating <int>, opponent_name <chr>, user_rating_diff <int>