Question 3 - NBA Player Boxscores, huxtable (18 marks)
Take the NBA Player Boxscore data provided and build a huxtable of the top 15 players in the league by
total points scored. The table should. . .
•
Include six columns: player name, position (most common if they have more than one), total points,
team, games played, and mean points per game. (3 marks)
•
Should have an alternating white-grey background for text cells.(2 marks)
•
Should have a solid border around and italic text on ONLY the games played of any player than played
75 or more games in the season. (This data only includes one regular season.) (3 marks)
•
Should round mean points to per game to the nearest 0.1. (2 marks)
•
Should have bolded column headers (i.e., variable names) (1 mark)
•
Should have human readable column headers. (e.g., “points”, not “pts”, and “position”, not “ath-
lete_position_name”) (2 marks)
•
Should have a border between the column headers and the rest of the data. (1 mark)
For full marks, show the table, and both the pipeline code used to arrange the data and the huxtable code.
(4 marks for arranging code)
Player name is
athlete_short_name
, position is
athlete_position_name
or
athlete_position_abbreviation
,
points is
pts
, team is
team_short_display_name
. Games played and mean points will need to be derived
by you.
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.2 --
## v ggplot2 3.3.6
v purrr
0.3.4
## v tibble
3.1.8
v dplyr
1.0.10
## v tidyr
1.2.1
v stringr 1.4.1
## v readr
2.1.3
v forcats 0.5.2
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()
masks stats::lag()
library(huxtable)
##
## Attaching package:
'
huxtable
'
##
## The following object is masked from
'
package:dplyr
'
:
##
##
add_rownames
##
## The following object is masked from
'
package:ggplot2
'
:
##
##
theme_grey
# Read Data from the csv File
data
<-
read.csv(
'
NBA_Player_Boxscore_2021-22.csv
'
)
# Take athlete data after grouping them by ID
# Take desired columns i.e. Name, most occuring
# position for each player, total points by each
# player, team of that player and number of games played
# Sort them by total points and add mean points per game.
# take top 15
top_athletes_data
<-
data %>%
2