Store hire bicycle data in SQLite3 database

store_bikedata(bikedb, city, data_dir, create_index = TRUE, dates = NULL,
  quiet = FALSE)

Arguments

bikedb

A string containing the path to the SQLite3 database to use. If it doesn't already exist, it will be created, otherwise data will be appended to existing database. If no directory specified, it is presumed to be in tempdir().

city

One or more cities for which to download and store bike data, or names of corresponding bike systems (see Details below).

data_dir

A character vector giving the directory containing the data files downloaded with dl_bikedata for one or more cities. Only if this parameter is missing will data be downloaded.

create_index

If TRUE, creates an index on the start and end station IDs and start and stop times.

dates

If specified and no data_dir is given, data are downloaded and stored only for these dates specified as vector of YYYYMM values.

quiet

If FALSE, progress is displayed on screen

Value

Number of trips added to database

Note

Data for different cities are all stored in the same database, with city identifiers automatically established from the names of downloaded data files. This function can take quite a long time to execute (typically > 10 minutes), and generates a SQLite3 database file several gigabytes in size. Downloaded data files are removed after loading into the database; files may be downloaded and stored permanently with dl_bikedata, and the corresponding data_dir passed to this function.

Details

City names are not case sensitive, and must only be long enough to unambiguously designate the desired city. Names of corresponding bike systems can also be given. Currently possible cities (with minimal designations in parentheses) and names of bike hire systems are:

New York City (ny)
Citibike
Washington, D.C. (dc)
Capital Bike Share
Chicago (ch)
Divvy Bikes
Los Angeles (la)
Metro Bike Share
Boston (bo)
Hubway

Examples

not_run({ data_dir <- tempdir () bike_write_test_data (data_dir = data_dir) # or download some real data! # dl_bikedata (city = 'la', data_dir = data_dir) bikedb <- file.path (data_dir, 'testdb') store_bikedata (data_dir = data_dir, bikedb = bikedb) trips <- bike_tripmat (bikedb = bikedb, city = 'LA') # trip matrix stations <- bike_stations (bikedb = bikedb) # station data bike_rm_test_data (data_dir = data_dir) bike_rm_db (bikedb) # don't forget to remove real data! # file.remove (list.files (data_dir, pattern = '.zip')) })