knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

This R package provides an abstraction layer for easily accessing openly available data sets for Winnipeg, MB, Canada.

Installation

In the future, you will be able to install the released version of winnipegr from CRAN with:

install.packages("winnipegr")

But, for now you need to use devtools:

install.packages("devtools")
devtools::install_github("jdallmann/winnipegr")

Retrieving Data

The package includes the following functions for downloading open data:

The package also contains internal fixed data sets. Load these data sets in the usual way data(transport_mode). Currently included data sets:

Examples

wpg_weather

This function uses the reim package to load Winnipeg weather abstracting station names. Measurements have the option to be converted to metric using the weathermetrics package.

\dontrun{
    wpg_weather(station = "forks",
        start = '2018-01-01',
        end = '2018-02-28',
        metric = TRUE)
    wpg_weather(station = "airport",
        start = '2018-01-01')
}

get_open_data

This function uses the RSocrata package to get Winnipeg City data from the Winnipeg Open Data site data.winnipeg.ca. Users with a City of Winnipeg open data account can also use their login credentials to have full (non-throttled) access to the API.

\dontrun{
    get_open_data("parking", app_token = SOME_API_TOKEN,
    email = FAKE_EMAIL,
    password = FAKE_PASSWORD)
\dontrun{
    get_open_data("river James")
}

get_transit

This function uses the rjson package to get Winnipeg City Transit data from the Winnipeg Transit API v3. It also flattens that data from json to a tidy dataframe. Users must have registered for their own (free) API key to use.

\dontrun{
    get_transit(option_vec = c("lat=49.8951",
                "lon=-97.1384", "distance=1000",
                "walking=true", "usage=short"),
                api_key = transit_API)
}


jdallmann/winnipegr documentation built on Jan. 20, 2020, 2:05 a.m.