-
Notifications
You must be signed in to change notification settings - Fork 17
How to add a new city
mark padgham edited this page Apr 18, 2018
·
7 revisions
Adding new cities to the package currently requires the following steps:
- Add city to
R/utils.R/convert_city_names
. - Add entry to
R/database-stats.R/bike_demographic_data
. - Write a routine to access the data files in
R/bikedata-files.R
, including adding entry inget_bike_files()
. - Update
R/storebikedata.R/get_bike_cities
and../get_flist_city
to automatically recognise the new files by their names. - Potentially change
R/date-time-functions.R/convert_dates_to_filenames
. - If the city has separate station data, either provided with the trip data or otherwise, then add city-specific function to
R/stations.R
, and list the station in the main loop ofR/store_bikedata
where it says, "import stations to station table". If the station data are included within the trip data, then add city to list inR/utils.R/data_has_stations
. - Examine the raw data files and ensure that the field (column) names all appear in the appropriate places in
data-raw/sysdata.Rmd
, or insert new ones. If new ones are inserted, then the whole script needs to be run to update the internal package data. If any new column names describe a different field to one that already exists, then individual city codes need to be entered, as for "la" and "mn" at the end of that script.
The data should be automatically parsed by the current C++ routines. This automatic parsing should only fail if files do not maintain the same structure throughout, as happens for a few cities in which patterns of quotation change. These require city-specific routines to be coded, which is far more laborious.
These cases need additional modifications to the R/store-bikedata.R
routines, following the pattern for other cities with raw .csv
files.
Test data for each new city also need to be created. This can be done at a later stage, but is done with this script:
bike_write_test_data (tempdir ())
bikedb <- file.path (getwd (), "testdb.sqlite")│
store_bikedata (data_dir = tempdir (), bikedb = bikedb)
index_bikedata_db (bikedb = bikedb)
Then the bikedb
is moved manually to /inst/data
.