knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(mountainbikeR) library(kableExtra)
mountainbikeR
packageHere we will write few words about the mountainbikeR
package.
my_mbr <- mountainbiker_initializer$new( my_app_name = Sys.getenv("STRAVA_APP_NAME") , my_client_id = Sys.getenv("STRAVA_CLIENT_ID") , my_client_secret = Sys.getenv("STRAVA_CLIENT_SECRET") , my_app_scope = "read,read_all,activity:read_all" , cache = TRUE )
We can now check few informations about our connection.
my_mbr$token$credentials$token_type my_mbr$token$credentials$expires_at substr(my_mbr$token$credentials$access_token,1,4) my_mbr$token$credentials$athlete$sex
Using the get_activities
method of the object we can get a list of activities.
# List activities some_activities_1 <- my_mbr$get_activities( activities_per_page = 200 , page_number = 1 #, after_date = "2018-01-01" ) some_activities_2 <- my_mbr$get_activities( activities_per_page = 200 , page_number = 2 #, after_date = "2018-01-01" ) some_activities <-rbind( some_activities_1 , some_activities_2 ) # Fields available names(some_activities) # Display some of the data head(some_activities$moving_time) head(some_activities$type)
library(ggplot2) g <- ggplot(data = some_activities[ type %in% c("Ride", "Run")]) g <- g + geom_point( mapping = aes( col = moving_time , y = total_elevation_gain , x = average_heartrate , shape = commute , size = distance ) , alpha = 0.7 ) g <- g + scale_color_gradient(low = "green", high = "red", na.value = "grey") g <- g + facet_grid(facets = . ~ type , scales = "free_x") g
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.