Goals of this Notebook

Setup

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6      ✔ purrr   0.3.4 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.0      ✔ stringr 1.4.1 
## ✔ readr   2.1.2      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(DT)
library(scales)
## 
## Attaching package: 'scales'
## 
## The following object is masked from 'package:purrr':
## 
##     discard
## 
## The following object is masked from 'package:readr':
## 
##     col_factor
library(lubridate)
## 
## Attaching package: 'lubridate'
## 
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union

Import data

bikes <- read_rds("data-processed/01-bikes.rds")

Creating new columns

First I’ll create a new column for year and month, so I can sort and filter by those variables.

bikes_c <- bikes |> 
  mutate(Month = month(Date)) |> 
  mutate(Year = year(Date)) |> 
  mutate(Trip_Duration = trip_duration_minutes) |> 
  mutate(Bicycle_ID = bicycle_id)

bikes_c

Create a searchable table for 2022 rides

First, I’ll filter to data after January 1, 2021 so the searchable table will work, since I have too much data to include all years.

bikes_recent <- bikes_c |> 
  filter(Year == 2022)

bikes_recent

Now I’ll filter to just the columns I want, and pivot the results to make the table.

bike_table <- bikes_recent |> 
  select(
    Bicycle_ID, Date, Trip_Duration, checkout_kiosk, return_kiosk
)

This table is searchable by Bicycle ID, which is printed on every MetroBike and sent in the confirmation email users receive after returning their bike. Simply type the bike number into the table to view every ride the bike took in 2022.

2022 MetroBike Trips

bike_table |> datatable()
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html

Happy Searching!