Blog post:

In this mini project, we created a graphic to investigate differences in hemoglobin concentrations between sports and between sexes. Our data came from Telford and Cunningham’s 1991 study entitled “Sex, sport, and body-size dependency of hematology in highly trained athletes.” In this study, blood was drawn from 706 Australian athletes six or more hours after a moderate to intense training session. Hemoglobin concentrations were determined from these blood tests. We created a boxplot to show variation in hemoglobin concentration between sports and sexes. Sexes are distinguished by color. Outliers are shown as black points either above or below a boxplot. Medians are represented by the horizontal lines inside the boxes.

Our data graphic is entitled “1991 Hemoglobin levels for Australian athletes.” Males showed higher concentrations of hemoglobin than females for all sports. The sports indicated on the x-axis of our graphic are ordered in terms of increasing median hemoglobin concentration, independent of sex. In their original study, Telford and Cunningham showed that a difference in hemoglobin levels existed between endurance-related events and power-related events. However, they failed to define which sports fell into which category in their abstract. We propose that sports such as basketball, tennis, and rowing are considered endurance-related events while sprinting and field sports are considered power-related events. The 400 meter dash and swimming fall between these two categories. Endurance athletes often show depleted hemoglobin levels after exercise as compared to power athletes. Our data graphic supports this belief.

Step 1: Load Data

library(tidyverse)
library(DAAG)
Australian_Athletes<- ais

Step 2: Load packages for kangaroo visual

packs <- c("png","grid")
lapply(packs, require, character.only = TRUE) 
## [[1]]
## [1] TRUE
## 
## [[2]]
## [1] TRUE
img <- readPNG("C:/Users/Melissa/Desktop/kangaroo (2).png") 
g <- rasterGrob(img, interpolate=TRUE) 

Step 3: Make visual

library(ggplot2)
library(dplyr)
facets <- c("Tennis", "B_Ball", "T_400m", "Row", "T_Sprnt", "Swim", "Field")
sports.sub <- ggplot(mapping = aes(x= reorder(sport, hg, median), y = hg, fill = sex), Australian_Athletes[Australian_Athletes$sport %in% facets,])+ 
  annotation_custom(g, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=19)+
    geom_boxplot(outlier.colour="black",
                outlier.size=3, colour = "gray47")
my_data_graphic <- sports.sub +
  labs(x = NULL, y = "[Hemoglobin] (g/dL)", title = "1991 Hemoglobin levels for Australian athletes", position = "center")+
  theme(axis.text.x = element_text(angle=35, vjust=0.5, colour = "black", size = 10))+
    scale_x_discrete(labels = c("B_Ball"="Basketball", "Row" = "Rowing", "T_400m" = "400m Dash", "Swim" = "Swimming", "T_Sprnt" = "Sprint", "Field" = "Field"), position = "bottom") +
  scale_fill_manual(values = c("m" = "darkblue", "f" = "red"), name = "Sex", breaks = c("m", "f"), labels = c("Male", "Female"))+
  theme(
  panel.background = element_rect(fill = "white", colour = "black"),
  panel.grid.major = element_line(colour = NA),
  panel.ontop = FALSE)
my_data_graphic

Acknowledgements

if(nchar(system.file(package="DAAG")))citation("DAAG")
## 
## To cite package 'DAAG' in publications use:
## 
##   John H. Maindonald and W. John Braun (2015). DAAG: Data Analysis
##   and Graphics Data and Functions. R package version 1.22.
##   https://CRAN.R-project.org/package=DAAG
## 
## A BibTeX entry for LaTeX users is
## 
##   @Manual{,
##     title = {DAAG: Data Analysis and Graphics Data and Functions},
##     author = {John H. Maindonald and W. John Braun},
##     year = {2015},
##     note = {R package version 1.22},
##     url = {https://CRAN.R-project.org/package=DAAG},
##   }
## 
## ATTENTION: This citation information has been auto-generated from
## the package DESCRIPTION file and may need manual editing, see
## 'help("citation")'.
if(nchar(system.file(package="dplyr")))citation("dplyr")
## 
## To cite package 'dplyr' in publications use:
## 
##   Hadley Wickham and Romain Francois (2016). dplyr: A Grammar of
##   Data Manipulation. R package version 0.5.0.
##   https://CRAN.R-project.org/package=dplyr
## 
## A BibTeX entry for LaTeX users is
## 
##   @Manual{,
##     title = {dplyr: A Grammar of Data Manipulation},
##     author = {Hadley Wickham and Romain Francois},
##     year = {2016},
##     note = {R package version 0.5.0},
##     url = {https://CRAN.R-project.org/package=dplyr},
##   }
if(nchar(system.file(package="png")))citation("png")
## 
## To cite package 'png' in publications use:
## 
##   Simon Urbanek (2013). png: Read and write PNG images. R package
##   version 0.1-7. https://CRAN.R-project.org/package=png
## 
## A BibTeX entry for LaTeX users is
## 
##   @Manual{,
##     title = {png: Read and write PNG images},
##     author = {Simon Urbanek},
##     year = {2013},
##     note = {R package version 0.1-7},
##     url = {https://CRAN.R-project.org/package=png},
##   }
## 
## ATTENTION: This citation information has been auto-generated from
## the package DESCRIPTION file and may need manual editing, see
## 'help("citation")'.
if(nchar(system.file(package="ggplot2")))citation("ggplot2")
## 
## To cite ggplot2 in publications, please use:
## 
##   H. Wickham. ggplot2: Elegant Graphics for Data Analysis.
##   Springer-Verlag New York, 2009.
## 
## A BibTeX entry for LaTeX users is
## 
##   @Book{,
##     author = {Hadley Wickham},
##     title = {ggplot2: Elegant Graphics for Data Analysis},
##     publisher = {Springer-Verlag New York},
##     year = {2009},
##     isbn = {978-0-387-98140-6},
##     url = {http://ggplot2.org},
##   }
if(nchar(system.file(package="readr")))citation("readr")
## 
## To cite package 'readr' in publications use:
## 
##   Hadley Wickham, Jim Hester and Romain Francois (2017). readr:
##   Read Rectangular Text Data. R package version 1.1.0.
##   https://CRAN.R-project.org/package=readr
## 
## A BibTeX entry for LaTeX users is
## 
##   @Manual{,
##     title = {readr: Read Rectangular Text Data},
##     author = {Hadley Wickham and Jim Hester and Romain Francois},
##     year = {2017},
##     note = {R package version 1.1.0},
##     url = {https://CRAN.R-project.org/package=readr},
##   }
if(nchar(system.file(package="DAAG")))citation("DAAG")
## 
## To cite package 'DAAG' in publications use:
## 
##   John H. Maindonald and W. John Braun (2015). DAAG: Data Analysis
##   and Graphics Data and Functions. R package version 1.22.
##   https://CRAN.R-project.org/package=DAAG
## 
## A BibTeX entry for LaTeX users is
## 
##   @Manual{,
##     title = {DAAG: Data Analysis and Graphics Data and Functions},
##     author = {John H. Maindonald and W. John Braun},
##     year = {2015},
##     note = {R package version 1.22},
##     url = {https://CRAN.R-project.org/package=DAAG},
##   }
## 
## ATTENTION: This citation information has been auto-generated from
## the package DESCRIPTION file and may need manual editing, see
## 'help("citation")'.
if(nchar(system.file()))citation()
## 
## To cite R in publications use:
## 
##   R Core Team (2017). R: A language and environment for
##   statistical computing. R Foundation for Statistical Computing,
##   Vienna, Austria. URL https://www.R-project.org/.
## 
## A BibTeX entry for LaTeX users is
## 
##   @Manual{,
##     title = {R: A Language and Environment for Statistical Computing},
##     author = {{R Core Team}},
##     organization = {R Foundation for Statistical Computing},
##     address = {Vienna, Austria},
##     year = {2017},
##     url = {https://www.R-project.org/},
##   }
## 
## We have invested a lot of time and effort in creating R, please
## cite it when using it for data analysis. See also
## 'citation("pkgname")' for citing R packages.