Extract summary statistics of database

bike_summary_stats(bikedb)

Arguments

bikedb

A string containing the path to the SQLite3 database. If no directory specified, it is presumed to be in tempdir().

Value

A data.frame containing numbers of trips and stations along with times and dates of first and last trips for each city in database and a final column indicating whether the files match the latest published versions.

Examples

data_dir <- tempdir () bike_write_test_data (data_dir = data_dir) # dl_bikedata (city = 'la', data_dir = '.') # or download some real data! bikedb <- file.path (data_dir, 'testdb') store_bikedata (data_dir = data_dir, bikedb = bikedb)
#> Creating sqlite3 database
#> Unzipping raw data files for ny ...
#> Reading files for ny ...
#> reading file 1/1: /tmp/Rtmp0qGggG/201612-citibike-tripdata.csv
#> Trips read for ny = 200
#> Unzipping raw data files for bo ...
#> Reading files for bo ...
#> reading file 1/1: /tmp/Rtmp0qGggG/201604-hubway-tripdata.csv
#> Trips read for bo = 200
#> Unzipping raw data files for ch ...
#> Reading files for ch ...
#> reading file 1/1: /tmp/Rtmp0qGggG/Divvy_Trips_sample.csv
#> Trips read for ch = 200
#> Unzipping raw data files for dc ...
#> Reading files for dc ...
#> reading file 1/1: /tmp/Rtmp0qGggG/2017-Q1-Trips-History-Data.csv
#> Trips read for dc = 200
#> Unzipping raw data files for la ...
#> Reading files for la ...
#> reading file 1/1: /tmp/Rtmp0qGggG/la_metro_gbfs_trips_Q1_2017.csv
#> Trips read for la = 198
#> Reading files for lo ...
#> reading file 1/1: /tmp/Rtmp0qGggG/01aJourneyDataExtract10Jan16-23Jan16.csv
#> Trips read for lo = 200
#> Total trips read = 1,198
#> Creating indexes
#> [1] 1198
bike_summary_stats ('testdb')
#> # A tibble: 7 x 5 #> num_trips num_stations first_trip last_trip latest_files #> * <dbl> <dbl> <fctr> <fctr> <lgl> #> 1 1198 2187 2016-01-10 00:00:00 2017-03-31 23:59:00 NA #> 2 200 93 2016-04-01 00:01:19 2016-04-01 07:49:26 FALSE #> 3 200 581 2016-12-31 19:04:56 2016-12-31 23:57:52 FALSE #> 4 200 456 2017-03-31 22:09:00 2017-03-31 23:59:00 FALSE #> 5 198 50 2017-01-01 00:15:00 2017-01-01 16:55:00 FALSE #> 6 200 774 2016-01-10 00:00:00 2016-01-10 01:08:00 FALSE #> 7 200 233 2016-12-01 00:00:04 2016-12-01 01:33:37 FALSE
bike_rm_test_data (data_dir = data_dir)
#> [1] 6
bike_rm_db (bikedb)
#> [1] TRUE
# don't forget to remove real data! # file.remove (list.files ('.', pattern = '.zip'))