Extract daily trip counts for all stations

bike_daily_trips(bikedb, city, station, member, birth_year, gender,
  standardise = FALSE)

Arguments

bikedb

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

city

City for which trips are to be counted - mandatory if database contains data for more than one city

station

Optional argument specifying bike station for which trips are to be counted

member

If given, extract only trips by registered members (member = 1 or TRUE) or not (member = 0 or FALSE).

birth_year

If given, extract only trips by registered members whose declared birth years equal or lie within the specified value or values.

gender

If given, extract only records for trips by registered users declaring the specified genders (f/m/. or 2/1/0).

standardise

If TRUE, daily trip counts are standardised to the relative numbers of bike stations in operation for each day, so daily trip counts are increased during (generally early) periods with relatively fewer stations, and decreased during (generally later) periods with more stations.

Value

A data.frame containing daily dates and total numbers of trips

Examples

bike_write_test_data () # by default in tempdir () # dl_bikedata (city = 'la', data_dir = '.') # or download some real data! bikedb <- file.path (tempdir (), 'testdb') store_bikedata (data_dir = tempdir (), 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_daily_trips (bikedb = 'testdb', city = 'ny')
#> # A tibble: 1 x 2 #> date numtrips #> <date> <int> #> 1 2016-12-01 200
bike_daily_trips (bikedb = 'testdb', city = 'ny', member = TRUE)
#> # A tibble: 1 x 2 #> date numtrips #> <date> <int> #> 1 2016-12-01 191
bike_daily_trips (bikedb = 'testdb', city = 'ny', gender = 'f')
#> # A tibble: 1 x 2 #> date numtrips #> <date> <int> #> 1 2016-12-01 22
bike_daily_trips (bikedb = 'testdb', city = 'ny', station = '173', gender = 1)
#> # A tibble: 1 x 2 #> date numtrips #> <date> <int> #> 1 2016-12-01 1
#> [1] 6
bike_rm_db (bikedb)
#> [1] TRUE
# don't forget to remove real data! # file.remove (list.files ('.', pattern = '.zip'))