# csv file
hockey <- read_csv("../00_data/myData_Hockey.csv")
hockey
## # A tibble: 251 × 10
## ...1 raw_rank player years total_goals url_number raw_link link active
## <dbl> <dbl> <chr> <chr> <dbl> <dbl> <chr> <chr> <chr>
## 1 1 1 Wayne Gret… 1979… 894 1 /player… http… Retir…
## 2 2 2 Gordie Howe 1946… 801 2 /player… http… Retir…
## 3 3 3 Jaromir Ja… 1990… 766 3 /player… http… Retir…
## 4 4 4 Brett Hull 1986… 741 4 /player… http… Retir…
## 5 5 5 Marcel Dio… 1971… 731 5 /player… http… Retir…
## 6 6 6 Phil Espos… 1963… 717 6 /player… http… Retir…
## 7 7 7 Mike Gartn… 1979… 708 7 /player… http… Retir…
## 8 8 8 Alex Ovech… 2005… 700 8 /player… http… Active
## 9 9 9 Mark Messi… 1979… 694 9 /player… http… Retir…
## 10 10 10 Steve Yzer… 1983… 692 10 /player… http… Retir…
## # ℹ 241 more rows
## # ℹ 1 more variable: yr_start <dbl>
# excel file
data <- read_excel("../00_data/Salaries.xlsx")
data
## # A tibble: 397 × 6
## rank discipline yrs.since.phd yrs.service sex salary
## <chr> <chr> <dbl> <dbl> <chr> <dbl>
## 1 Prof B 19 18 Male 139750
## 2 Prof B 20 16 Male 173200
## 3 AsstProf B 4 3 Male 79750
## 4 Prof B 45 39 Male 115000
## 5 Prof B 40 41 Male 141500
## 6 AssocProf B 6 6 Male 97000
## 7 Prof B 30 23 Male 175000
## 8 Prof B 45 45 Male 147765
## 9 Prof B 21 20 Male 119250
## 10 Prof B 18 18 Female 129000
## # ℹ 387 more rows
ggplot(hockey, aes(x = player, y = total_goals)) +
geom_bar(stat = "identity")
ggplot(hockey, aes(x = player, y = total_goals)) +
geom_boxplot() +
labs(title = "Total Goals Per Player")
ggplot(hockey, aes(x = player <26, y = total_goals)) +
geom_boxplot() +
labs(title = "Total Goals Per Player Top 25")
In order to more easily visualize a section of data, I intuitively put“<26” in ggplot function to only plot the top 25 players and their respective goal amounts. I was wondering if there is a different and more repeatable way to do this with a subsection of data.