Quickly Importing Athlete Management System (AMS) Data into R

One question I have had recently pop up is “How can I directly import my athlete management system (AMS) into R for statistical analysis?”

Athlete Management Systems are great tools to capture, report and quickly visualise data. The system I am most familiar with, Smartabase, is excellent for creating customised forms and now has a cool dashboard feature whereby teams can create flexible visualisations on the platform.

But what if you wish to run a linear mixed-model or random forest on data captured within AMS? You could run a report, as per the Smartabase example, and then download all your raw data to .csv format, save it on your machine and import into R. Alternatively, you can use html tools within R to quickly import your data and not even open a web browser! To do this, please follow the steps below.

Note – I am using Smartabase as an example here because it is familiar to me. Please get in contact if you have an alternate system!

  1. Save a report of your data within Smartabase. For example, save a report that contains all historical athlete wellness data.
  2. Open R and use the code below to import your data. Note, you will need to add your own username/ password/ URL details that are specific to your team.
# Load required packages
library(rvest)
library(plyr)
library(dplyr)
library(qdap)

# Connect to a report that you have generated via Smartabase
WellnessDataURL <- html_session("https://username:[email protected]/yourteamsname/live?report=WellnessData&updategroup=true")
# Read in data
WellnessData <- read_html(WellnessDataURL)
# Identify the table
WellnessDataTable <- html_nodes(WellnessData, "table")
# Collect only table data
WellnessDataTable1 <- html_table(WellnessDataTable[1], fill = TRUE)
# Make data.frame
HistoricalWellnessData <- as.data.frame(WellnessDataTable1)
# Clean Environment
rm(list = grep("^HistoricalWellnessData", ls(), value = TRUE, invert = TRUE))

Now your AMS data is in a neat data.frame and ready for any further statistical analysis or visualisation using R, without needing to open a web browser!