• 1 Start by Loading Libraries
  • 2 Import and Read file
  • 3 Data exploration: Trauma incidents over time for 2019
  • 4 Data Exploration: Trauma indidents per body part and age
  • 5 Exploring Data for Head Injuries
  • 6 The Diagnosis Most Commonly Associated with Head Injury
  • 7 Head Injuries in People of 40 years and Younger
  • 8 Exploring Concussion and Sport’s Injuries

1 Start by Loading Libraries

library(tidyverse)
-- Attaching packages -------------------------------------- tidyverse 1.3.0 --
v ggplot2 3.3.0     v purrr   0.3.4
v tibble  3.0.1     v dplyr   0.8.5
v tidyr   1.0.3     v stringr 1.4.0
v readr   1.3.1     v forcats 0.5.0
-- Conflicts ----------------------------------------- tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()
library(extrafont)
Registering fonts with R
library(ggthemes)
library(ggplot2)
library(gt)
library(readxl)
library(devtools)
Loading required package: usethis
library(here)
here() starts at C:/Users/koles/Downloads
library(viridis)
Loading required package: viridisLite

2 Import and Read file

newtraumadata <- read_excel("C:/Users/koles/Downloads/newtraumadata.xlsx")
New names:
* `` -> ...1
head(newtraumadata)
# A tibble: 6 x 14
   ...1 Treatment_Date        Age Sex   Race  BodyPart Diagnosis1 Disposition
  <dbl> <dttm>              <dbl> <chr> <chr> <chr>    <chr>      <chr>      
1     0 2019-01-01 00:00:00    81 Male  Not ~ LOWER T~ FRACTURE   TREATED AN~
2     1 2019-01-01 00:00:00    38 Fema~ Not ~ LOWER L~ FRACTURE   TREATED AN~
3     2 2019-01-01 00:00:00    94 Male  Not ~ HEAD     INTERNAL ~ TREATED AN~
4     3 2019-01-01 00:00:00    86 Male  Not ~ HEAD     INTERNAL ~ TREATED AN~
5     4 2019-01-01 00:00:00    87 Fema~ Not ~ ELBOW    CONTUSION~ TREATED AN~
6     5 2019-01-01 00:00:00    47 Male  Not ~ SHOULDER FRACTURE   TREATED AN~
# ... with 6 more variables: Location <chr>, Product1 <chr>, Product2 <chr>,
#   Product3 <chr>, Alcohol <chr>, Drugs <chr>

3 Data exploration: Trauma incidents over time for 2019

ggplot(newtraumadata, aes(x=Treatment_Date))+
  geom_histogram(fill = "white", colour = "black")+
  labs(x="Treatment Date", y="Number of Injuries")+
  ggtitle("Trauma incidents 2019")
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

4 Data Exploration: Trauma indidents per body part and age

# Filtering the dataset to group the data by age, body part, and product

per_body_part <- newtraumadata %>%
  group_by(Age, Race, BodyPart, Product1,Diagnosis1,Disposition) %>%
  summarize(num_children=n())
ggplot(per_body_part, mapping = aes(x=BodyPart, y=num_children, colour = Age))+
  geom_col()+
  labs(x="Body Part", y="Number of Injuries")+
  scale_x_discrete(breaks=c('ANKLE', 'FACE', 'HEAD', 'FINGER', 'LOWER TRUNK', 'UPPER TRUNK'))+
  ggtitle("Most Commonly Injured Body Part")+
  scale_color_viridis(option = "inferno", begin = 1, end = 0)+
  theme(axis.text.x = element_text(angle=60, hjust=1))

5 Exploring Data for Head Injuries

head_injury <- filter(per_body_part, (BodyPart=='HEAD')) 

6 The Diagnosis Most Commonly Associated with Head Injury

ggplot(head_injury, mapping = aes(x=Diagnosis1, y=num_children, colour = Age))+
  geom_col()+
  labs(x="Diagnosis", y="Number of Injuries")+
  scale_x_discrete(breaks=c('CONCUSSION','INTERNAL INJURY', 'LACERATION', 'CONTUSION ABR', 'HEMATOMA','FRACTURE', 'OTHER'))+
  ggtitle("Diagnosis Most Commonly Associated with Head Injury")+
  scale_color_viridis(option = "inferno", begin = 1, end = 0)+
  theme(axis.text.x = element_text(angle=60, hjust=1))

7 Head Injuries in People of 40 years and Younger

head_injury_under_40 <- filter(head_injury, (Age<41))

ggplot(head_injury_under_40, mapping = aes(x=Diagnosis1, y=num_children, colour = Age))+
  geom_col()+
  labs(x="Diagnosis", y="Number of Injuries")+
  scale_x_discrete(breaks=c('CONCUSSION','INTERNAL INJURY', 'LACERATION', 'CONTUSION ABR', 'HEMATOMA','FRACTURE', 'OTHER'))+
  ggtitle("Diagnosis Most Commonly Associated with Head Injury")+
  scale_color_viridis(option = "inferno", begin = 1, end = 0)+
  theme(axis.text.x = element_text(angle=60, hjust=1))

8 Exploring Concussion and Sport’s Injuries

# Data manipulations
vector <- c('BASEBALL (ACTIVITY APPAREL OR EQUIPMENT; EXCL SOFTBALL)','BICYCLES AND ACCESSORIES (EXCL.MOUNTAIN OR ALL,TERRAIN)',
      'TRAMPOLINES','BASEBALL, ACTIVITY AND RELATED EQUIPMENT', 'VOLLEYBALL (ACTIVITY APPAREL OR EQUIPMENT)',
      'SOCCER (ACTIVITY APPAREL OR EQUIPMENT)','SPORTS AND RECREATIONAL ACTIVITY N.E.C.', 'ICE HOCKEY (ACTIVITY APPAREL OR EQUIPMENT)',
      'SKATEBOARDS', 'WRESTLING (ACTIVITY APPAREL OR EQUIPMENT)', 'SCOOTERS / SKATEBOARDS POWERED', 'MONKEY BARS OR OTHER PLAYGROUND CLIMBING APPARATUS',
      'LACROSSE (ACTIVITY APPAREL OR EQUIPMENT)', 'SNOW SKIING (ACTIVITY APPAREL OR EQUIPMENT)')
      
diagnosis <- c('CONCUSSION', 'INTERNAL INJURY')

concussion <- filter(head_injury_under_40, (Diagnosis1 %in% diagnosis &  Product1 %in% vector)) %>%
  group_by(Age, Race, BodyPart, Product1,Diagnosis1,Disposition) %>%
  summarize(num_children=n())
# The plot
ggplot(concussion, aes(x=Product1, y=num_children,
  colour = Age))+
  geom_col()+
  labs(x="Sport", y="Number of Injuries")+
  ggtitle("Sports Most Commonly Associated with Concussion and Internal Injury")+
  scale_color_viridis(option = "inferno", begin = 1, end = 0)+
  theme(axis.text.x = element_text(angle=60, hjust=1))