Git Product home page Git Product logo

velib's Introduction

## velib
##### a way to access data from the Paris bike network

-----

##### Installing the `velib` R Package

```r
install.packages("devtools")
require(devtools)
install_github("brian-bot/velib")
```

-----

##### Overview

* sign up, get your apiKey, and see API documentation at [JCDecaux](https://developer.jcdecaux.com/#/opendata/vls?page=getstarted)
* more about [velib in Paris](http://en.velib.paris.fr/)

-----

##### Quickstart Guide

```r
## 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")
```

velib's People

Contributors

brian-bot avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.