Results Pivot - Overview Data GC Time/GC Time from Leader showing NAs
Closed this issue · 1 comments
rogers1000 commented
GC Time
and GC Time from Leader
aren't working in pivot table.
Likely related to
races_selected <- dplyr::pull(results_pivot_filters |>
select(first_cycling_race_id) |>
unique() |>
summarise(count = n()),count)
results_pivot_races_count <- results_pivot_filters |>
filter(position_edit_gc < 1000) |>
group_by(pivot_id) |>
summarise(races_count = n_distinct(first_cycling_race_id))
results_pivot_sort <- results_pivot_filters |>
filter(position_edit_gc < 1000) |>
group_by(pivot_id,season,first_cycling_race_id,stage) |>
summarise(best_result_gc = min(position_edit_gc),
gc_time_edit = min(gc_time_edit),
gc_time_from_leader_edit = min(gc_time_from_leader_edit)) |>
ungroup() |>
group_by(pivot_id,stage) |>
summarise(avg_position_gc = mean(best_result_gc),
total_gc_time = sum(gc_time_edit),
total_gc_time_from_leader = sum(gc_time_from_leader_edit),
races_finished = n()) |>
ungroup() |>
mutate(total_gc_time = case_when(races_finished == races_selected ~ NA,
.default = total_gc_time)) |>
mutate(total_gc_time_from_leader = case_when(races_finished == races_selected ~ NA,
.default = total_gc_time_from_leader))
rogers1000 commented
Easy fix, error in case_when
.
mutate(total_gc_time = case_when(races_finished == races_selected ~ NA,
.default = total_gc_time)) |>
mutate(total_gc_time_from_leader = case_when(races_finished == races_selected ~ NA,
.default = total_gc_time_from_leader))```
changed to
mutate(total_gc_time = case_when(races_finished != races_selected ~ NA,
.default = total_gc_time)) |>
mutate(total_gc_time_from_leader = case_when(races_finished != races_selected ~ NA,
.default = total_gc_time_from_leader))