cf_open | R Documentation |
cf_open()
retrieves data from the CrossFit Open API, lightly pre-processed.
If you need low level access to the API, use cf_request()
.
If no data is returned by the API, an empty tibble with zero columns and zero rows is returned.
You'll typically need to use tidyr::unnest_wider()
and tidyr::hoist()
to further process this data.
This function will automatically paginate through the data. To avoid overloading the API, it will not perform more than 100 requests per minute.
cf_open( year, ..., division = cf_division$Men, scale = cf_scale$rx, affiliate = NULL, n_pages = NULL, progress = TRUE )
year |
The year to retrieve data for. Note that not all parameters will be valid for past years. |
... |
These dots are for future extensions and must be empty. |
division |
The division to retrieve data for. One of the values in cf_division. |
scale |
The workout scale to retrieve data for. One of the values in cf_scale. |
affiliate |
An optional integer ID to only retrieve data about a particular affiliate. |
n_pages |
An optional integer to limit the number of pages returned. Each page will have a maximum of 100 rows returned. This is useful if you just want to explore the data without downloading all of it. If not specified, this will download all available data. |
progress |
Should a progress bar be shown for longer downloads? |
A tibble.
library(tidyr) library(dplyr) top_100 <- cf_open(2022, n_pages = 1) top_100 %>% unnest_wider(entrant) %>% hoist(scores, one = 1) %>% select(competitorName, one) %>% unnest_wider(one) %>% select(competitorName, score, breakdown) # CrossFit Huntersville affiliate <- 16292 cf_open(2022, division = cf_division$Women, affiliate = affiliate) %>% unnest_wider(entrant) %>% hoist(scores, two = 2) %>% select(competitorName, two) %>% unnest_wider(two) %>% select(competitorName, score, breakdown)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.