Analyzing Crossfit Athletes with R-Shiny
Weekend (Data) Warrior
For many of us, New Year == New You: a running start to all those exercise, eating and wellbeing programs we never quite got to last year. There's evidence that the most-common new year's resolution among Americans is to exercise more, and that more healthy living is a goal for almost a third of us.
Like half a million other people around the world, my activity of choice is Crossfit. Although I've been doing it for five years, I resolved this year to increase my Crossfit knowledge, engagement and mojo. Rather than actually go to the gym, I decided to build an interactive R Shiny app that could help me and other Crossfitters to analyze the performance of competitive athletes, looking for patterns that can lead to gains.
The data consisted of two files. (They can be accessed here and here, and previous analyses can be found here and here.) One contained of over 1.5 million records of athlete performance at various Crossfit events, including the annual Open, which attracts hundreds of thousands of people like me with dreams of ESPN Crossfit Games glory. The other file had 423,000 rows of 28 attributes, most of which were self-reported by athletes, including times on standard workouts, weightlifting loads, and answers to survey questions about diet, background, lifestyle and routines.
The data files could be joined on Athlete ID, which is unique to each registered athlete.
Note: If you'd like just like to interact with the app -- it's pretty self-explanatory -- you can jump right to it here.
The primary questions I was hoping to answer with the help of the app were:
- Is there a competitive benefit to focusing on cardio or weightlifting, both of which feature in the Crossfit program?
- What is the impact of body-mass index (BMI) on the different types of activities?
- Is there a background or routine that leads to better performance in competitions?
In particular, I wanted to reach some conclusions about how athletes who performed well at sanctioned events trained and focused their time. Someday, I mused, I might be one of them ....
Building the R Shiny App
The primary challenge was missing and suspicious data. The sanctioned event response data was reliable because it was official and simply had to be deduplicated around Athlete ID and checked for missing rows, which were removed.
The self-reported data was a different matter. Many athletes left many responses blank, for various reasons. Because the results are idiosyncratic to the athlete, I did not feel comfortable imputing values. Some data were obvious erroneous -- either entered in error or deliberately fudged. For example, a number of athletes entered times for "running a 400K" that were faster than the world record or slower than a nap. I created a probable range of reasonableness and removed outliers.
Survey questions about diet and lifestyle were self-reported and not ideally structured. They were contained within a single string with multiple responses allowed. For simplicity, I selected the first response.
Building the App
I wanted to have an easy-to-use app that had three tabs. The areas of interest were:
- Benchmarks: Let an athlete see how their times/loads for various standard workouts compared to others in their cohort.
- Competitor Benchmarks: Explore how athletes who finished at various levels in ranked competitions did on these same workouts.
- Lifestyle Factors: Finally, I wanted athletes to be able to see survey responses to questions about diet, training, etc. from athletes who ranked at some chosen level -- in order to compare "winners" vs. "others"
My app used the basic format of ui.R, server.R and global.R. My toggles were related to selecting cohorts. In cohorts, there are divisions made between men and women (for competition and for benchmarking), as well as for adults over and under 35 years old (with 35 yrs + considered a "Masters" athlete). Body-mass index (BMI) is not a competitive variable but is important in gauging individual performance; as you should know, it's a general representation of height/weight proportions.
A design note: I wanted the toggles in the sidebar to be different for each tab, showing only the relevant inputs. I was able to do this by setting up a mainPanel, 3 tabsetPanels and 3 conditionalPanels. Snippets are shown here:
The final UI for the first tab used boxplots to indicate the distribution of the self-reported scores for various benchmark workouts. The workouts themselves are listed at the bottom of the screen. Note that Crossfit gives standard workouts names (like "Fran") and calls them WODs (for Workout-of-the-Day). Yes, you could call it a feel-good cult.
What I Learned about Crossfit
Is there a competitive benefit to focusing on Cardio or Weightlifting?
Running vs. WODs: Basically, there is less variability in running ability than there is in weightlifting for various cohorts. This makes intuitive sense: running is more of a general marker of cardio health than weightlifting, which requires both health and specific skill in the movement.
Weightlifting: There are more outliers on the high-end in the hard-core weightlifting events. So there seems to be a more concentrated group of gifted lifters than there are people who are generally good at endurance. This again points to the importance of improving weightlifting vs. cardio for competitive excellence.
Elites: Speaking of elites, there is definitely a bright line between the top 10K or so athletes and the rest of us -- they regularly outperform in competition and run us ragged. So only those in the top 10K or so (which is, say, the top 4-5% of serious Crossfitters) are elite. This separation is even more pronounced among women.
What is the impact of BMI on different types of activities?
BMI: It's the most important factor we have in the data. Surprisingly, BMI has more impact on performance than age or gender. Remember that BMI is simply an indication of how "dense" your body is -- it's possible to have an outsized BMI (above the mean for your age/gender) by being obese or by being heavily muscled. So it's not equivalent to being out of shape. The data bears this up: higher BMIs predicted lower cardio scores but higher weightlifting scores.
Older Athletes: Based on survey responses, older athletes (35+) were more careful with their diets and were even less likely to perform well with a higher BMI index. The lesson here is that while BMI is critical in all age groups, it gets more important with age to stay relatively lean.
Is there a background or routine that leads to better performance?
Background: Both men and women who performed well at Crossfit events quite often started working out alone (with no coach), and many have only been doing Crossfit for a couple of years. So the lesson is it's okay to start small and don't assume you need years of experience to win.
Secret: The single lifestyle factor that seemed to have the biggest impact on performance was simple: the number of workouts per week. Better athletes work out more often than also-rans. It's an old story but apparently true: work it, it's worth it.
You can access the app's source code at my Github repo
The Shiny app itself can be enjoyed here