Learn R Programming

injurytools

Overview

injurytools is a package designed for the field of Sports Medicine. It simplifies the data analysis workflow by providing convenience functions and handy tools for sports injury and illness data.

The functions can be classified into: (a) sports injury and illness data preparation, (b) descriptive analyses and (c) data visualization routines. Further analyses, such as the estimation of the risk of injury/illness (any sports-related health problem) with other covariate effects, can be performed outside of injurytools, whether the event of health problem is viewed as count or time-to-event data.

To get an overview of the package, see the Articles section.

In practice, the package can automate specific descriptive reports that are routinely generated for sports injury and illness surveillance.

Installation

To install from CRAN:

install.packages("injurytools")

To install the most current version from GitHub:

devtools::install_github("lzumeta/injurytools")

Usage

Functions for data preparation start with prepare_*(), those for estimating epidemiological measures start with calc_*(), and those for data visualization with gg_*().

The below outlines at a glance how injurytools can help to get a comprehensive picture of sports injury and illness data:

library(injurytools)
library(ggplot2)

(p <- gg_photo(injd, 
               title   = "Injury overview of Liverpool FC's men's first team, 2017-2018 and 2018-2019 seasons",
               by_date = "2 month") +
    ## plus some lines of ggplot2 code..
    xlab("Follow-up date") + ylab("Players") + 
    labs(caption = "source: transfermarkt.com") +
    theme(axis.text.x.bottom = element_text(size = 13, angle = 20, hjust = 1),
          axis.text.y.left   = element_text(size = 12),
          axis.title.x = element_text(size = 20, face = "bold", vjust = -1),
          axis.title.y = element_text(size = 20, face = "bold", vjust = 1.8),
          legend.text  = element_text(size = 20),
          legend.position = "top",
          plot.caption = element_text(face = "italic", size = 12, colour = "gray10"),
          plot.title = element_text(face = "bold", hjust = 0.5, size = 22),
          plot.title.position = "plot")
)
p +
  ## add days lost info
  geom_text(aes(x = date_injured + days_lost/2, y = person_id, label = paste0(days_lost, " days")), 
            vjust = -0.5, data = injd) +
  scale_y_discrete(expand = expansion(mult = 0.05))
p + 
  ## add injury info
  geom_text(aes(x = date_injured + days_lost/2, y = person_id, label = injury),
            vjust = -0.5, data = injd) +
  scale_y_discrete(expand = expansion(mult = 0.05))

How to contribute

If you have problems with the package, find any bugs, or have suggestions for improvements, please feel free to open a GitHub issue or touch us directly via email. We also welcome your feedback.

Copy Link

Version

Install

install.packages('injurytools')

Monthly Downloads

311

Version

2.0.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Lore Zumeta Olaskoaga

Last Published

January 26th, 2026

Functions in injurytools (2.0.1)

get_data_exposures

Extract exposures data frame
gg_photo

Plot injuries and illnesses over the follow-up period
gg_prevalence

Plot bar plots representing players' prevalence
check_injfollowup

Check the dates in injury data and exposure data
gg_rank

Plot athlete's health problem incidence or burden ranking
get_data_followup

Extract follow-up data frame
get_data_injuries

Extract injury/illness data frame
is_injd

Check if an object is of class injd
label_unit

Label the time unit
date2season

Get the season
season2year

Get the year
gg_riskmatrix

Plot risk matrices
raw_df_exposures

Minimal example of exposure data
raw_df_injuries

Minimal example of injury data
injd

Example of an injd object
date_format

Proper Conversion of Date objects
injurytools

injurytools package
summary_unit

Transform calc_summary() output according to the unit of exposure
cut_injd

Cut the range of the follow-up
prepare_data

Prepare data in a standardized format
validate_injd

validator or injd class
new_injd

constructor of injd class
calc_ndayslost

Calculate number of days lost
calc_exposure

Calculate the exposure time
calc_ncases

Calculate number of cases
calc_incidence

Calculate case incidence rate
calc_burden

Calculate case burden rate
calc_iqr_dayslost

Calculate the interquartile range days lost
calc_median_dayslost

Calculate the median days lost
calc_mean_dayslost

Calculate the mean days lost
calc_prevalence

Calculate prevalence proportion
calc_summary

Calculate summary statistics
data_injurieslong

Transform injury data into a long format
data_followup

Build follow-up data frame
exp_unit_suffix

Obtain suffix for time exposure unit