velib
R Packageinstall.packages("devtools") require(devtools) install_github("brian-bot/velib")
## LOAD THE PACKAGE require(velib) ## USE API KEY TO AUTHENTICATE setApiKey("myApiKey12345") ## GET ALL OF THE CONTRACTS cs <- velibRestGET('contracts') ## GET VELIB CONTRACT idx <- sapply(cs, function(x){ x$commercial_name=="Velib" }) velibContract <- cs[[ which(idx) ]] ## GET THE STATIONS FOR THE VELIB CONTRACT stns <- velibRestGET(paste0("stations?contract=", velibContract$name)) stnsNew <- lapply(stns, function(x){ x$last_update <- as.POSIXct(x$last_update/1000, origin="1970-01-01") x$position <- paste0(x$position, collapse=":") return(as.data.frame(x)) }) ## CONVERT TO A DATAFRAME AND ONLY LOOK AT OPEN STATIONS df <- do.call(rbind, stnsNew) df <- df[ df$status=="OPEN", ] ## PLOT AVAILABLE BIKES BY BONUS STATUS require(ggplot2) densPlot <- ggplot(df, aes(x=available_bikes, fill=factor(bonus))) + geom_density(alpha=0.3) + ggtitle("Available Bikes by Bonus Status")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.