Package 'oystr'

Title: Handle Personal Oyster Journey History Data Provided by Transport for London
Description: You can opt-in to monthly emails from Transport for London (TfL) that have your Oyster journey history attached as a CSV. Functions in this small package help you read, wrangle and summarise these data. I, and this work, are unaffiliated with Transport for London (TfL).
Authors: Matt Dray [aut, cre]
Maintainer: Matt Dray <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2024-11-01 06:25:37 UTC
Source: https://github.com/matt-dray/oystr

Help Index


Example Oyster Journey History File (Cleaned)

Description

An anonymised example of a single month's journey history data received originally as a CSV from Transport for London, read with oy_read() and cleaned with oy_clean().

Usage

data(journeys_clean)

Format

An object of class "data.frame".

Source

Data generated and received originally from (Transport for London).

Examples

data(journeys_clean)

Example Oyster Journey History File (Read In)

Description

An anonymised example of a single month's journey history data received originally as a CSV from Transport for London and read with oy_read().

Usage

data(journeys_read)

Format

An object of class data.frame.

Source

Data generated and received originally from (Transport for London).

Examples

data(journeys_read)

Clean Oyster journey history data

Description

Process a data.frame object containing Oyster journey history data. Could be a raw file as received by email from Transport for London or the output from oy_read().

Usage

oy_clean(x)

Arguments

x

A data.frame object containing Oyster journey history.

Value

A data.frame objectwith 13 columns and as many rows as journeys.

Examples

## Not run: 
my_df <- oy_read("path/to/folder/")
my_df_clean <- oy_clean(my_df)

## End(Not run)

Transport for London Colours

Description

A named vector of hexadecimal colour values from Transport for London's colour standard. Includes corporate, mode-specific and safety colours, as well as London Underground line colours.

Usage

oy_cols(...)

Arguments

...

Provide either the names or indices of colours in the vector (see details).

Details

An empty call returns the whole vector. The colour names are as follows:

  • corporate: corporate_blue, corporate_red, corporate_grey, corporate_dark_grey, corporate_yellow, corporate_green, corporate_black, corporate_white

  • mode-specific: transport_for_london, line_elizabeth, london_overground, emirates_air_line, santander_cycles, london_river_services, london_underground, london_buses, london_dial_a_ride, taxi_private_hire, visitor_centre, london_coaches, docklands_light_railway, tfl_rail

  • safety: safety_blue, corporate_red, corporate_yellow, corporate_green

  • London Underground lines: line_bakerloo, line_hammersmith_city, line_piccadilly, line_central, line_jubilee, line_victoria, line_circle, line_metropolitan, line_waterloo_city, line_district, line_northern

  • other logos and identities: oyster_blue, oyster_cyan, legible_london_blue, legible_london_yellow

Value

A named vector object.

Examples

oy_cols()  # return full named vector
oy_cols("oyster_blue", "oyster_cyan")  # return named values
oy_cols(1:5)  # return first five elements

Line Plot of Oyster Journey Data

Description

Outputs a simple time series line plot of Oyster journey data that's been cleaned with oy_clean.

Usage

oy_lineplot(
  data,
  x_var = "datetime_start",
  y_var = "journey_duration",
  weekdays = FALSE,
  mode = "Train"
)

Arguments

data

data.frame of Oyster journey history data cleaned using oy_clean().

x_var

The name of the variable from data that you want on the x axis. This is restricted currently to datetime_start.

y_var

The name of the continuous variable from data for the y axis. Choose "journey_duration" or "balance".

weekdays

Logical. FALSE returns data for all days of the week. Restrict the output to Monday to Friday with TRUE.

mode

Currently restricted to "Train".

Value

A plot.

Examples

## Not run: 
my_df <- oy_read("path/to/folder/")
my_df_clean <- oy_clean(my_df)
oy_lineplot(my_df_clean, y_var = "Balance", weekdays = FALSE)

## End(Not run)

Read Oyster Journey History Files

Description

Read one or more Oyster journey history files from a single folder and combine them. Assumes journey histories are raw CSV files as received by email from Transport for London. Ignores files that are not identified as Oyster history journey files.

Usage

oy_read(path)

Arguments

path

A string describing a filepath to a folder of Oyster journey history CSV files.

Value

A data.frame object with 8 columns and as many rows as journeys.

Examples

## Not run: 
my_df <- oy_read("path/to/folder/")

## End(Not run)

Simple Summary Statistics of Oyster Journeys

Description

Generate simple summaries of your Oyster journey history data for a quick overview.

Usage

oy_summary(data, mode = "Train")

Arguments

data

Data frame output from link{oy_clean()}.

mode

Currently restricted to "Train".

Value

A list object where each element is some kind of data summary.

Examples

## Not run: 
my_df <- oy_read("path/to/folder/")
my_df_clean <- oy_clean(my_df)
oy_summary(my_df_clean, mode = "Train")

## End(Not run)