# data was manually created from kenpomseason <- tibble::tribble(~Season,~Games,~Type,~Values,"2021-22",39,"Threes",32.4,"2021-22",39,"Twos",49.2,"2021-22",39,"Free Throws",18.4,"2022-23",11,"Threes",23.6,"2022-23",11,"Twos",51.9,"2022-23",11,"Free Throws",24.5)# load csv from sportsreferenceassists <-read_csv('assists_turnovers.csv')
Manipulate data and make tables
Code
# season tableseason_tb <- season %>%group_by(Season) %>%summarize(list_data =list(Values)) %>%arrange(Season)join_season <- season %>%group_by(Season) %>%summarize(Games = Games[1])final_season <-merge(season_tb, join_season, by ="Season") %>%select(Season, Games, list_data)ff <- final_season %>%gt() %>%gt_plt_bar_stack(column = list_data,width =50,labels =c("Threes", "Twos", "Free Throws"),palette =c("#d38956", "#56a0d3", "#d356a0"),fmt_fn = scales::label_number(accuracy =0.1) ) %>%gt_theme_nytimes() %>%# set title + caption + subtitletab_header(title ="Points distribution under Hubert Davis",subtitle ="Percentage of points scored from three-pointers, two-pointers, and free throws.") %>%tab_source_note(source_note ="@dadgumboxscores | December 14, 2022") %>%# fix font of source notetab_options (source_notes.font.size =px(10),table.font.size =px(12)) ff
Points distribution under Hubert Davis
Percentage of points scored from three-pointers, two-pointers, and free throws.