├── .gitignore
├── figures
├── hex.png
└── plot-1.png
├── docs
├── favicon.ico
├── favicon-16x16.png
├── favicon-32x32.png
├── apple-touch-icon.png
├── reference
│ ├── Rplot001.png
│ ├── figures
│ │ └── hex.png
│ ├── data
│ │ ├── station_status.rds
│ │ ├── system_alerts.rds
│ │ ├── system_hours.rds
│ │ ├── system_regions.rds
│ │ ├── free_bike_status.rds
│ │ ├── system_calendar.rds
│ │ ├── station_information.rds
│ │ ├── system_information.rds
│ │ └── system_pricing_plans.rds
│ ├── gbfs_data
│ │ ├── station_status.rds
│ │ ├── system_alerts.rds
│ │ ├── system_hours.rds
│ │ ├── system_regions.rds
│ │ ├── free_bike_status.rds
│ │ ├── system_calendar.rds
│ │ ├── station_information.rds
│ │ ├── system_information.rds
│ │ └── system_pricing_plans.rds
│ ├── kc_gbfs
│ │ └── station_status.rds
│ ├── slcbikes
│ │ ├── station_status.rds
│ │ ├── system_regions.rds
│ │ ├── station_information.rds
│ │ ├── system_information.rds
│ │ └── system_pricing_plans.rds
│ ├── get_gbfs_cities.html
│ ├── index.html
│ ├── get_system_pricing_plans.html
│ ├── gbfs.html
│ ├── get_system_hours.html
│ ├── get_system_alerts.html
│ ├── get_system_calendar.html
│ ├── get_which_gbfs_feeds.html
│ └── get_system_regions.html
├── apple-touch-icon-120x120.png
├── apple-touch-icon-152x152.png
├── apple-touch-icon-180x180.png
├── apple-touch-icon-60x60.png
├── apple-touch-icon-76x76.png
├── pkgdown.yml
├── link.svg
├── sitemap.xml
├── bootstrap-toc.css
├── docsearch.js
├── jquery.sticky-kit.min.js
├── pkgdown.js
├── articles
│ └── index.html
├── bootstrap-toc.js
├── 404.html
├── authors.html
├── CONTRIBUTING.html
└── pkgdown.css
├── tests
├── testthat.R
└── testthat
│ ├── test-static-feeds.R
│ ├── test-wrapper.R
│ ├── test-dynamic-feeds.R
│ └── test-utils.R
├── man
├── figures
│ └── hex.png
├── get_gbfs_cities.Rd
├── get_which_gbfs_feeds.Rd
├── get_system_pricing_plans.Rd
├── get_system_hours.Rd
├── get_system_calendar.Rd
├── get_system_alerts.Rd
├── get_station_information.Rd
├── get_free_bike_status.Rd
├── gbfs.Rd
├── get_station_status.Rd
├── get_system_regions.Rd
├── get_system_information.Rd
└── get_gbfs.Rd
├── pkgdown
└── favicon
│ ├── favicon.ico
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── apple-touch-icon.png
│ ├── apple-touch-icon-60x60.png
│ ├── apple-touch-icon-76x76.png
│ ├── apple-touch-icon-120x120.png
│ ├── apple-touch-icon-152x152.png
│ └── apple-touch-icon-180x180.png
├── cran-comments.md
├── .Rbuildignore
├── codecov.yml
├── gbfs.Rproj
├── NAMESPACE
├── DESCRIPTION
├── CONTRIBUTING.md
├── .github
└── workflows
│ └── R-CMD-check.yaml
├── R
├── get_dynamic_feeds.R
├── gbfs_description.R
├── get_gbfs.R
└── get_static_feeds.R
├── NEWS.md
└── README.Rmd
/.gitignore:
--------------------------------------------------------------------------------
1 | .Rproj.user
2 | .Rhistory
3 | .RData
4 | .Ruserdata
5 |
--------------------------------------------------------------------------------
/figures/hex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/figures/hex.png
--------------------------------------------------------------------------------
/docs/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/favicon.ico
--------------------------------------------------------------------------------
/figures/plot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/figures/plot-1.png
--------------------------------------------------------------------------------
/tests/testthat.R:
--------------------------------------------------------------------------------
1 | library(testthat)
2 | library(gbfs)
3 |
4 | test_check("gbfs")
5 |
--------------------------------------------------------------------------------
/man/figures/hex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/man/figures/hex.png
--------------------------------------------------------------------------------
/docs/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/favicon-16x16.png
--------------------------------------------------------------------------------
/docs/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/favicon-32x32.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/apple-touch-icon.png
--------------------------------------------------------------------------------
/docs/reference/Rplot001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/Rplot001.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/pkgdown/favicon/favicon.ico
--------------------------------------------------------------------------------
/docs/reference/figures/hex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/figures/hex.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/docs/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/pkgdown/favicon/favicon-16x16.png
--------------------------------------------------------------------------------
/pkgdown/favicon/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/pkgdown/favicon/favicon-32x32.png
--------------------------------------------------------------------------------
/docs/pkgdown.yml:
--------------------------------------------------------------------------------
1 | pandoc: '3.2'
2 | pkgdown: 2.1.0
3 | pkgdown_sha: ~
4 | articles: {}
5 | last_built: 2025-01-13T16:19Z
6 |
--------------------------------------------------------------------------------
/docs/reference/data/station_status.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/data/station_status.rds
--------------------------------------------------------------------------------
/docs/reference/data/system_alerts.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/data/system_alerts.rds
--------------------------------------------------------------------------------
/docs/reference/data/system_hours.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/data/system_hours.rds
--------------------------------------------------------------------------------
/docs/reference/data/system_regions.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/data/system_regions.rds
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/pkgdown/favicon/apple-touch-icon.png
--------------------------------------------------------------------------------
/docs/reference/data/free_bike_status.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/data/free_bike_status.rds
--------------------------------------------------------------------------------
/docs/reference/data/system_calendar.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/data/system_calendar.rds
--------------------------------------------------------------------------------
/docs/reference/data/station_information.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/data/station_information.rds
--------------------------------------------------------------------------------
/docs/reference/data/system_information.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/data/system_information.rds
--------------------------------------------------------------------------------
/docs/reference/gbfs_data/station_status.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/gbfs_data/station_status.rds
--------------------------------------------------------------------------------
/docs/reference/gbfs_data/system_alerts.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/gbfs_data/system_alerts.rds
--------------------------------------------------------------------------------
/docs/reference/gbfs_data/system_hours.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/gbfs_data/system_hours.rds
--------------------------------------------------------------------------------
/docs/reference/gbfs_data/system_regions.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/gbfs_data/system_regions.rds
--------------------------------------------------------------------------------
/docs/reference/kc_gbfs/station_status.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/kc_gbfs/station_status.rds
--------------------------------------------------------------------------------
/docs/reference/slcbikes/station_status.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/slcbikes/station_status.rds
--------------------------------------------------------------------------------
/docs/reference/slcbikes/system_regions.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/slcbikes/system_regions.rds
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-60x60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/pkgdown/favicon/apple-touch-icon-60x60.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-76x76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/pkgdown/favicon/apple-touch-icon-76x76.png
--------------------------------------------------------------------------------
/docs/reference/data/system_pricing_plans.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/data/system_pricing_plans.rds
--------------------------------------------------------------------------------
/docs/reference/gbfs_data/free_bike_status.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/gbfs_data/free_bike_status.rds
--------------------------------------------------------------------------------
/docs/reference/gbfs_data/system_calendar.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/gbfs_data/system_calendar.rds
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-120x120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/pkgdown/favicon/apple-touch-icon-120x120.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-152x152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/pkgdown/favicon/apple-touch-icon-152x152.png
--------------------------------------------------------------------------------
/pkgdown/favicon/apple-touch-icon-180x180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/pkgdown/favicon/apple-touch-icon-180x180.png
--------------------------------------------------------------------------------
/docs/reference/gbfs_data/station_information.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/gbfs_data/station_information.rds
--------------------------------------------------------------------------------
/docs/reference/gbfs_data/system_information.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/gbfs_data/system_information.rds
--------------------------------------------------------------------------------
/docs/reference/slcbikes/station_information.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/slcbikes/station_information.rds
--------------------------------------------------------------------------------
/docs/reference/slcbikes/system_information.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/slcbikes/system_information.rds
--------------------------------------------------------------------------------
/docs/reference/slcbikes/system_pricing_plans.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/slcbikes/system_pricing_plans.rds
--------------------------------------------------------------------------------
/docs/reference/gbfs_data/system_pricing_plans.rds:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simonpcouch/gbfs/HEAD/docs/reference/gbfs_data/system_pricing_plans.rds
--------------------------------------------------------------------------------
/cran-comments.md:
--------------------------------------------------------------------------------
1 | ## gbfs
2 |
3 | There were no ERRORs, WARNINGs, or NOTEs in checks.
4 |
5 | The package currently has no reverse dependencies.
6 |
7 |
--------------------------------------------------------------------------------
/.Rbuildignore:
--------------------------------------------------------------------------------
1 | ^.*\.Rproj$
2 | ^\.Rproj\.user$
3 | docs/
4 | ^README.Rmd
5 | ^README.md
6 | NEWS.Rmd
7 | figures/
8 | ^codecov\.yml$
9 | ^CRAN-RELEASE$
10 | CONTRIBUTING.md
11 | ^pkgdown
12 | ^\.github$
13 | ^cran-comments\.md$
14 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | comment:
2 | layout: "reach, diff, flags, files"
3 | behavior: default
4 | require_changes: false # if true: only post the comment if coverage changes
5 | require_base: no # [yes :: must have a base report to post]
6 | require_head: yes # [yes :: must have a head report to post]
7 | branches: null
8 |
--------------------------------------------------------------------------------
/gbfs.Rproj:
--------------------------------------------------------------------------------
1 | Version: 1.0
2 |
3 | RestoreWorkspace: Default
4 | SaveWorkspace: Default
5 | AlwaysSaveHistory: Default
6 |
7 | EnableCodeIndexing: Yes
8 | UseSpacesForTab: Yes
9 | NumSpacesForTab: 2
10 | Encoding: UTF-8
11 |
12 | RnwWeave: Sweave
13 | LaTeX: pdfLaTeX
14 |
15 | BuildType: Package
16 | PackageUseDevtools: Yes
17 | PackageInstallArgs: --no-multiarch --with-keep.source
18 |
--------------------------------------------------------------------------------
/NAMESPACE:
--------------------------------------------------------------------------------
1 | # Generated by roxygen2: do not edit by hand
2 |
3 | export(get_free_bike_status)
4 | export(get_gbfs)
5 | export(get_gbfs_cities)
6 | export(get_station_information)
7 | export(get_station_status)
8 | export(get_system_alerts)
9 | export(get_system_calendar)
10 | export(get_system_hours)
11 | export(get_system_information)
12 | export(get_system_pricing_plans)
13 | export(get_system_regions)
14 | export(get_which_gbfs_feeds)
15 | importFrom(dplyr,"%>%")
16 |
--------------------------------------------------------------------------------
/tests/testthat/test-static-feeds.R:
--------------------------------------------------------------------------------
1 | context("static feeds")
2 |
3 |
4 | test_that("static feeds work", {
5 |
6 | skip_if_offline(host = "r-project.org")
7 |
8 | get_station_information("https://gbfs.lyft.com/gbfs/1.1/pdx/en/station_information.json")
9 |
10 | get_system_alerts("https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_alerts.json")
11 |
12 | get_system_calendar("https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_calendar.json")
13 |
14 | get_system_hours("https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_hours.json")
15 |
16 | get_system_information("https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_information.json")
17 |
18 | get_system_regions("https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_regions.json")
19 | })
20 |
--------------------------------------------------------------------------------
/man/get_gbfs_cities.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_gbfs.R
3 | \name{get_gbfs_cities}
4 | \alias{get_gbfs_cities}
5 | \title{Get table of all cities releasing GBFS feeds}
6 | \source{
7 | North American Bikeshare Association, General Bikeshare Feed Specification
8 | \url{https://raw.githubusercontent.com/MobilityData/gbfs/master/systems.csv}
9 | }
10 | \usage{
11 | get_gbfs_cities()
12 | }
13 | \value{
14 | A \code{data.frame} of all cities issuing GBFS feeds. The `Auto-Discovery URL`
15 | column supplies the relevant .json feeds, while the entries in the `URL` column
16 | take the user to the public-facing webpage of the programs.
17 | }
18 | \description{
19 | Get table of all cities releasing GBFS feeds
20 | }
21 |
--------------------------------------------------------------------------------
/docs/link.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
13 |
--------------------------------------------------------------------------------
/DESCRIPTION:
--------------------------------------------------------------------------------
1 | Package: gbfs
2 | Type: Package
3 | Title: Interface with Live Bikeshare Data
4 | Version: 1.3.10.9000
5 | Authors@R: c(
6 | person("Simon P.", "Couch", , "simonpatrickcouch@gmail.com", c("aut", "cre")),
7 | person("Kaelyn", "Rosenberg", , "kaerosenberg@gmail.com", c("aut")),
8 | person("Mark", "Padgham", , "mark.padgham@email.com", c("ctb")))
9 | Description: Supplies a set of functions to interface with bikeshare data
10 | following the General Bikeshare Feed Specification, allowing users to query
11 | and accumulate tidy datasets for specified cities/bikeshare programs.
12 | License: CC0
13 | Imports:
14 | dplyr,
15 | readr,
16 | stringr,
17 | jsonlite,
18 | lubridate,
19 | httr,
20 | purrr,
21 | curl
22 | Encoding: UTF-8
23 | RoxygenNote: 7.3.0
24 | Suggests:
25 | knitr,
26 | rmarkdown,
27 | testthat (>= 2.1.0),
28 | covr
29 | URL: https://github.com/simonpcouch/gbfs
30 | BugReports: https://github.com/simonpcouch/gbfs/issues
31 |
--------------------------------------------------------------------------------
/docs/sitemap.xml:
--------------------------------------------------------------------------------
1 |
2 | /404.html
3 | /CONTRIBUTING.html
4 | /articles/index.html
5 | /articles/kc_bikeshare.html
6 | /authors.html
7 | /index.html
8 | /news/index.html
9 | /reference/gbfs.html
10 | /reference/get_free_bike_status.html
11 | /reference/get_gbfs.html
12 | /reference/get_gbfs_cities.html
13 | /reference/get_station_information.html
14 | /reference/get_station_status.html
15 | /reference/get_system_alerts.html
16 | /reference/get_system_calendar.html
17 | /reference/get_system_hours.html
18 | /reference/get_system_information.html
19 | /reference/get_system_pricing_plans.html
20 | /reference/get_system_regions.html
21 | /reference/get_which_gbfs_feeds.html
22 | /reference/index.html
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributor Code of Conduct
2 |
3 | As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4 |
5 | We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6 |
7 | Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8 |
9 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, issues, and other contributions that are not aligned to this Code of Conduct.
10 |
11 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12 |
13 | This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at https://www.contributor-covenant.org/version/1/0/0/code-of-conduct.html
14 |
--------------------------------------------------------------------------------
/man/get_which_gbfs_feeds.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_gbfs.R
3 | \name{get_which_gbfs_feeds}
4 | \alias{get_which_gbfs_feeds}
5 | \title{Get dataframe of bikeshare feeds released by a city}
6 | \source{
7 | North American Bikeshare Association, General Bikeshare Feed
8 | Specification \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
9 | }
10 | \usage{
11 | get_which_gbfs_feeds(city)
12 | }
13 | \arguments{
14 | \item{city}{A character string that can be matched to a gbfs feed. The recommended
15 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
16 | also attempt to match to the URL of an active .json feed or city name.}
17 | }
18 | \value{
19 | A \code{data.frame} containing the feeds supplied by
20 | a city. . The `feed` column supplies the name of the relevant .json feeds,
21 | while the entries in the `URL` column supply the feeds themselves.
22 | }
23 | \description{
24 | Of the different types of feeds supplied by the gbfs,
25 | some are required, some are conditionally required, and some are
26 | optional. This function grabs a list of each of the feeds supplied
27 | by a given city, as well as the URLs to access them.
28 | }
29 | \examples{
30 | # grab all of the feeds released by portland
31 | \donttest{get_which_gbfs_feeds(city = "biketown_pdx")}
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/.github/workflows/R-CMD-check.yaml:
--------------------------------------------------------------------------------
1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3 | on:
4 | push:
5 | branches: [main, master]
6 | pull_request:
7 | branches: [main, master]
8 |
9 | name: R-CMD-check
10 |
11 | jobs:
12 | R-CMD-check:
13 | runs-on: ${{ matrix.config.os }}
14 |
15 | name: ${{ matrix.config.os }} (${{ matrix.config.r }})
16 |
17 | strategy:
18 | fail-fast: false
19 | matrix:
20 | config:
21 | - {os: macos-latest, r: 'release'}
22 | - {os: windows-latest, r: 'release'}
23 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
24 | - {os: ubuntu-latest, r: 'release'}
25 | - {os: ubuntu-latest, r: 'oldrel-1'}
26 |
27 | env:
28 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
29 | R_KEEP_PKG_SOURCE: yes
30 |
31 | steps:
32 | - uses: actions/checkout@v3
33 |
34 | - uses: r-lib/actions/setup-pandoc@v2
35 |
36 | - uses: r-lib/actions/setup-r@v2
37 | with:
38 | r-version: ${{ matrix.config.r }}
39 | http-user-agent: ${{ matrix.config.http-user-agent }}
40 | use-public-rspm: true
41 |
42 | - uses: r-lib/actions/setup-r-dependencies@v2
43 | with:
44 | extra-packages: any::rcmdcheck
45 | needs: check
46 |
47 | - uses: r-lib/actions/check-r-package@v2
48 | with:
49 | upload-snapshots: true
50 |
--------------------------------------------------------------------------------
/tests/testthat/test-wrapper.R:
--------------------------------------------------------------------------------
1 | context("wrapper")
2 |
3 | # grab the feed for portland's biketown... these feeds
4 | # change regularly, so test failures might result from
5 | # changes in the operation model of biketown rather than
6 | # failure of the software
7 |
8 | biketown <- tryCatch(
9 | get_gbfs("biketown_pdx"),
10 | error = function(e) {e}
11 | )
12 |
13 | if (inherits(biketown, "error")) {
14 | skip("no internet connection or deprecated bikeshare system")
15 | }
16 |
17 | bike_itau <- tryCatch(
18 | get_gbfs("santiago"),
19 | error = function(e) {e}
20 | )
21 |
22 | if (inherits(bike_itau, "error")) {
23 | skip("no internet connection or deprecated bikeshare system")
24 | }
25 |
26 | chicago_url <- "https://gbfs.divvybikes.com/gbfs/2.3/gbfs.json"
27 |
28 | if (url_exists(chicago_url)) {
29 | chicago <- tryCatch(
30 | get_gbfs(chicago_url),
31 | error = function(e) {e}
32 | )
33 |
34 | if (inherits(chicago, "error")) {
35 | skip("deprecated bikeshare system")
36 | }
37 | } else {
38 | skip("no internet connection")
39 | }
40 |
41 | test_that("main wrapper works", {
42 |
43 | skip_if_offline(host = "r-project.org")
44 |
45 | expect_equal(class(biketown), "list")
46 | expect_equal(class(bike_itau), "list")
47 | expect_equal(class(chicago), "list")
48 |
49 | })
50 |
51 | test_that("argument checking works", {
52 |
53 | skip_if_offline(host = "r-project.org")
54 |
55 | # no directory supplied but user wants to save
56 | expect_error(get_gbfs("biketown_pdx",
57 | output = "save"),
58 | "The argument to output suggests")
59 |
60 | })
61 |
--------------------------------------------------------------------------------
/tests/testthat/test-dynamic-feeds.R:
--------------------------------------------------------------------------------
1 | context("dynamic feeds")
2 |
3 |
4 | test_that("dynamic feeds work", {
5 |
6 | skip_if_offline(host = "r-project.org")
7 |
8 | get_station_status("biketown_pdx")
9 |
10 | get_free_bike_status("biketown_pdx")
11 |
12 | })
13 |
14 | test_that("file saving and overwriting works", {
15 |
16 | skip("row-binding trips up on GHA")
17 |
18 | # make a temporary directory
19 | dir <- tempdir()
20 |
21 | # save the file to a subdirectory of it
22 | get_station_status("biketown_pdx", paste0(dir, "/test"))
23 |
24 | # ...and then append to it
25 | get_station_status("biketown_pdx", paste0(dir, "/test"))
26 |
27 | })
28 |
29 | test_that("row binding checks work", {
30 |
31 | skip_if_offline(host = "r-project.org")
32 |
33 | # make a temporary directory
34 | dir <- tempdir()
35 |
36 | # grab some data to work with
37 | pdx_status <- get_station_status("biketown_pdx", dir, output = "both")
38 |
39 | # try to overwrite it, but...
40 |
41 | # ... with a column pulled off
42 | pdx_status_ <- pdx_status %>%
43 | dplyr::select(-station_id)
44 |
45 | expect_error(datasets_can_be_row_binded(
46 | pdx_status_,
47 | paste0(dir, "/station_status.rds")),
48 | "columns, while")
49 |
50 | # ... or a column name changed
51 | pdx_status_ <- pdx_status %>%
52 | dplyr::rename(stationId = station_id)
53 |
54 | expect_error(datasets_can_be_row_binded(
55 | pdx_status_,
56 | paste0(dir, "/station_status.rds")),
57 | "has different column names")
58 |
59 | # ... or different column types
60 | pdx_status_ <- pdx_status %>%
61 | dplyr::mutate(station_id = as.factor(station_id))
62 |
63 | expect_error(datasets_can_be_row_binded(
64 | pdx_status_,
65 | paste0(dir, "/station_status.rds")),
66 | "has different column types")
67 |
68 | })
69 |
--------------------------------------------------------------------------------
/man/get_system_pricing_plans.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_static_feeds.R
3 | \name{get_system_pricing_plans}
4 | \alias{get_system_pricing_plans}
5 | \title{Grab the system_pricing_plans feed.}
6 | \usage{
7 | get_system_pricing_plans(
8 | city,
9 | directory = NULL,
10 | file = "system_pricing_plans.rds",
11 | output = NULL
12 | )
13 | }
14 | \arguments{
15 | \item{city}{A character string that can be matched to a gbfs feed. The recommended
16 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
17 | also attempt to match to the URL of an active .json feed or city name.}
18 |
19 | \item{directory}{Optional. Path to a folder (or folder to be
20 | created) where the feed will be saved.}
21 |
22 | \item{file}{Optional. The name of the file to be saved (if \code{output}
23 | is set to \code{"save"} or \code{"both"}), as a character string.
24 | Must end in \code{".rds"}.}
25 |
26 | \item{output}{Optional. The type of output method. If left as default, this
27 | argument is inferred from the \code{directory} argument. If
28 | \code{output = "save"}, the object will be saved as an .rds object at
29 | # the given path. If \code{output = "return"}, the output will be returned
30 | as a dataframe object. Setting \code{output = "both"} will do both.}
31 | }
32 | \value{
33 | The output of this function depends on argument to \code{output}
34 | and \code{directory}. Either a saved .rds object generated from the current
35 | feed, a dataframe object, or both.
36 | }
37 | \description{
38 | \code{get_system_pricing_plans} grabs and tidies the system_pricing_plans
39 | feed for a given city. Metadata for this dataset can be found at:
40 | \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
41 | }
42 | \seealso{
43 | [get_gbfs()] for a wrapper to call each of the \code{get_feed}
44 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
45 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
46 | are released by a given city.
47 | }
48 |
--------------------------------------------------------------------------------
/docs/bootstrap-toc.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/)
3 | * Copyright 2015 Aidan Feldman
4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */
5 |
6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */
7 |
8 | /* All levels of nav */
9 | nav[data-toggle='toc'] .nav > li > a {
10 | display: block;
11 | padding: 4px 20px;
12 | font-size: 13px;
13 | font-weight: 500;
14 | color: #767676;
15 | }
16 | nav[data-toggle='toc'] .nav > li > a:hover,
17 | nav[data-toggle='toc'] .nav > li > a:focus {
18 | padding-left: 19px;
19 | color: #563d7c;
20 | text-decoration: none;
21 | background-color: transparent;
22 | border-left: 1px solid #563d7c;
23 | }
24 | nav[data-toggle='toc'] .nav > .active > a,
25 | nav[data-toggle='toc'] .nav > .active:hover > a,
26 | nav[data-toggle='toc'] .nav > .active:focus > a {
27 | padding-left: 18px;
28 | font-weight: bold;
29 | color: #563d7c;
30 | background-color: transparent;
31 | border-left: 2px solid #563d7c;
32 | }
33 |
34 | /* Nav: second level (shown on .active) */
35 | nav[data-toggle='toc'] .nav .nav {
36 | display: none; /* Hide by default, but at >768px, show it */
37 | padding-bottom: 10px;
38 | }
39 | nav[data-toggle='toc'] .nav .nav > li > a {
40 | padding-top: 1px;
41 | padding-bottom: 1px;
42 | padding-left: 30px;
43 | font-size: 12px;
44 | font-weight: normal;
45 | }
46 | nav[data-toggle='toc'] .nav .nav > li > a:hover,
47 | nav[data-toggle='toc'] .nav .nav > li > a:focus {
48 | padding-left: 29px;
49 | }
50 | nav[data-toggle='toc'] .nav .nav > .active > a,
51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a,
52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a {
53 | padding-left: 28px;
54 | font-weight: 500;
55 | }
56 |
57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */
58 | nav[data-toggle='toc'] .nav > .active > ul {
59 | display: block;
60 | }
61 |
--------------------------------------------------------------------------------
/man/get_system_hours.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_static_feeds.R
3 | \name{get_system_hours}
4 | \alias{get_system_hours}
5 | \title{Grab the system_hours feed.}
6 | \usage{
7 | get_system_hours(
8 | city,
9 | directory = NULL,
10 | file = "system_hours.rds",
11 | output = NULL
12 | )
13 | }
14 | \arguments{
15 | \item{city}{A character string that can be matched to a gbfs feed. The recommended
16 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
17 | also attempt to match to the URL of an active .json feed or city name.}
18 |
19 | \item{directory}{Optional. Path to a folder (or folder to be
20 | created) where the feed will be saved.}
21 |
22 | \item{file}{Optional. The name of the file to be saved (if \code{output}
23 | is set to \code{"save"} or \code{"both"}), as a character string.
24 | Must end in \code{".rds"}.}
25 |
26 | \item{output}{Optional. The type of output method. If left as default, this
27 | argument is inferred from the \code{directory} argument. If
28 | \code{output = "save"}, the object will be saved as an .rds object at
29 | # the given path. If \code{output = "return"}, the output will be returned
30 | as a dataframe object. Setting \code{output = "both"} will do both.}
31 | }
32 | \value{
33 | The output of this function depends on argument to \code{output}
34 | and \code{directory}. Either a saved .rds object generated from the current
35 | feed, a dataframe object, or both.
36 | }
37 | \description{
38 | \code{get_system_hours} grabs and tidies the system_hours
39 | feed for a given city. Metadata for this
40 | dataset can be found at:
41 | \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
42 | }
43 | \examples{
44 | # grab the system hours feed for portland, oregon
45 | \donttest{get_system_hours(city =
46 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_hours.json",
47 | output = "return")}
48 |
49 | }
50 | \seealso{
51 | [get_gbfs()] for a wrapper to call each of the \code{get_feed}
52 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
53 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
54 | are released by a given city.
55 | }
56 |
--------------------------------------------------------------------------------
/man/get_system_calendar.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_static_feeds.R
3 | \name{get_system_calendar}
4 | \alias{get_system_calendar}
5 | \title{Grab the system_calendar feed.}
6 | \usage{
7 | get_system_calendar(
8 | city,
9 | directory = NULL,
10 | file = "system_calendar.rds",
11 | output = NULL
12 | )
13 | }
14 | \arguments{
15 | \item{city}{A character string that can be matched to a gbfs feed. The recommended
16 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
17 | also attempt to match to the URL of an active .json feed or city name.}
18 |
19 | \item{directory}{Optional. Path to a folder (or folder to be
20 | created) where the feed will be saved.}
21 |
22 | \item{file}{Optional. The name of the file to be saved (if \code{output}
23 | is set to \code{"save"} or \code{"both"}), as a character string.
24 | Must end in \code{".rds"}.}
25 |
26 | \item{output}{Optional. The type of output method. If left as default, this
27 | argument is inferred from the \code{directory} argument. If
28 | \code{output = "save"}, the object will be saved as an .rds object at
29 | # the given path. If \code{output = "return"}, the output will be returned
30 | as a dataframe object. Setting \code{output = "both"} will do both.}
31 | }
32 | \value{
33 | The output of this function depends on argument to \code{output}
34 | and \code{directory}. Either a saved .rds object generated from the current
35 | feed, a dataframe object, or both.
36 | }
37 | \description{
38 | \code{get_system_calendar} grabs and tidies the system_calendar feed
39 | for a given city. Metadata for this dataset can be found at:
40 | \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
41 | }
42 | \examples{
43 | # grab the system calendar feed for portland, oregon
44 | \donttest{get_system_calendar(city =
45 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_calendar.json",
46 | output = "return")}
47 |
48 |
49 | }
50 | \seealso{
51 | [get_gbfs()] for a wrapper to call each of the \code{get_feed}
52 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
53 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
54 | are released by a given city.
55 | }
56 |
--------------------------------------------------------------------------------
/man/get_system_alerts.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_static_feeds.R
3 | \name{get_system_alerts}
4 | \alias{get_system_alerts}
5 | \title{Grab the system_alerts feed.}
6 | \usage{
7 | get_system_alerts(
8 | city,
9 | directory = NULL,
10 | file = "system_alerts.rds",
11 | output = NULL
12 | )
13 | }
14 | \arguments{
15 | \item{city}{A character string that can be matched to a gbfs feed. The recommended
16 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
17 | also attempt to match to the URL of an active .json feed or city name.}
18 |
19 | \item{directory}{Optional. Path to a folder (or folder to be
20 | created) where the feed will be saved.}
21 |
22 | \item{file}{Optional. The name of the file to be saved (if \code{output}
23 | is set to \code{"save"} or \code{"both"}), as a character string.
24 | Must end in \code{".rds"}.}
25 |
26 | \item{output}{Optional. The type of output method. If left as default, this
27 | argument is inferred from the \code{directory} argument. If
28 | \code{output = "save"}, the object will be saved as an .rds object at
29 | # the given path. If \code{output = "return"}, the output will be returned
30 | as a dataframe object. Setting \code{output = "both"} will do both.}
31 | }
32 | \value{
33 | The output of this function depends on argument to \code{output}
34 | and \code{directory}. Either a saved .rds object generated from the current
35 | feed, a dataframe object, or both.
36 | }
37 | \description{
38 | \code{get_system_alerts} grabs and tidies the system_alerts feed for a given city.
39 | This feed informs users about changes to normal operation. Metadata for this
40 | dataset can be found at: \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
41 | }
42 | \examples{
43 | # grab the system alerts feed for portland, oregon
44 | \donttest{get_system_alerts(city =
45 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_alerts.json",
46 | output = "return")}
47 |
48 | }
49 | \seealso{
50 | [get_gbfs()] for a wrapper to call each of the \code{get_feed}
51 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
52 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
53 | are released by a given city.
54 | }
55 |
--------------------------------------------------------------------------------
/docs/docsearch.js:
--------------------------------------------------------------------------------
1 | $(function() {
2 |
3 | // register a handler to move the focus to the search bar
4 | // upon pressing shift + "/" (i.e. "?")
5 | $(document).on('keydown', function(e) {
6 | if (e.shiftKey && e.keyCode == 191) {
7 | e.preventDefault();
8 | $("#search-input").focus();
9 | }
10 | });
11 |
12 | $(document).ready(function() {
13 | // do keyword highlighting
14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */
15 | var mark = function() {
16 |
17 | var referrer = document.URL ;
18 | var paramKey = "q" ;
19 |
20 | if (referrer.indexOf("?") !== -1) {
21 | var qs = referrer.substr(referrer.indexOf('?') + 1);
22 | var qs_noanchor = qs.split('#')[0];
23 | var qsa = qs_noanchor.split('&');
24 | var keyword = "";
25 |
26 | for (var i = 0; i < qsa.length; i++) {
27 | var currentParam = qsa[i].split('=');
28 |
29 | if (currentParam.length !== 2) {
30 | continue;
31 | }
32 |
33 | if (currentParam[0] == paramKey) {
34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20"));
35 | }
36 | }
37 |
38 | if (keyword !== "") {
39 | $(".contents").unmark({
40 | done: function() {
41 | $(".contents").mark(keyword);
42 | }
43 | });
44 | }
45 | }
46 | };
47 |
48 | mark();
49 | });
50 | });
51 |
52 | /* Search term highlighting ------------------------------*/
53 |
54 | function matchedWords(hit) {
55 | var words = [];
56 |
57 | var hierarchy = hit._highlightResult.hierarchy;
58 | // loop to fetch from lvl0, lvl1, etc.
59 | for (var idx in hierarchy) {
60 | words = words.concat(hierarchy[idx].matchedWords);
61 | }
62 |
63 | var content = hit._highlightResult.content;
64 | if (content) {
65 | words = words.concat(content.matchedWords);
66 | }
67 |
68 | // return unique words
69 | var words_uniq = [...new Set(words)];
70 | return words_uniq;
71 | }
72 |
73 | function updateHitURL(hit) {
74 |
75 | var words = matchedWords(hit);
76 | var url = "";
77 |
78 | if (hit.anchor) {
79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor;
80 | } else {
81 | url = hit.url + '?q=' + escape(words.join(" "));
82 | }
83 |
84 | return url;
85 | }
86 |
--------------------------------------------------------------------------------
/R/get_dynamic_feeds.R:
--------------------------------------------------------------------------------
1 | #' Grab the free_bike_status feed.
2 | #'
3 | #' Grab a dataframe giving the geographic location and other metadata of
4 | #' bikeshare bikes not parked at bikeshare stations. Metadata for this dataset
5 | #' can be found at: \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
6 | #'
7 | #' @inherit get_station_information params seealso
8 | #'
9 | #' @return The output of this function depends on the argument to \code{output}
10 | #' and \code{directory}. Either a saved .rds object generated from the current
11 | #' station_information feed, a dataframe object, or both. If a saved feed of
12 | #' the same type already exists at the filepath, the feed will be appended to
13 | #' rather than overwritten.
14 | #'
15 | #' @examples
16 | #' # grab the free bike status feed for portland, oregon's bikeshare program
17 | #' \donttest{get_free_bike_status(city =
18 | #' "https://gbfs.lyft.com/gbfs/1.1/pdx/en/free_bike_status.json",
19 | #' output = "return")}
20 | #'
21 | #' @export
22 | get_free_bike_status <- function(city, directory = NULL, file = "free_bike_status.rds", output = NULL) {
23 |
24 | get_gbfs_dataset_(city, directory, file, output, feed = "free_bike_status")
25 |
26 | }
27 |
28 | #' Grab the station_status feed.
29 | #'
30 | #' Grab a dataframe giving the geographic location and other metadata of
31 | #' bikeshare bikes parked at bikeshare stations. Metadata for this dataset
32 | #' can be found at: \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
33 | #'
34 | #' @inherit get_station_information params seealso
35 | #'
36 | #' @inherit get_free_bike_status return
37 | #'
38 | #' @examples
39 | #' # we can grab the free bike status feed for portland,
40 | #' # oregon's bikeshare program in several ways! the most
41 | #' # straightforward way is just to supply the `city` argument
42 | #' # as a string:
43 | #' \donttest{get_station_status(city = "biketown_pdx")}
44 | #'
45 | #' # the `city` argument can also be supplied as an
46 | #' # actual URL to an active .json feed
47 | #' \donttest{get_station_status(city =
48 | #' "https://gbfs.lyft.com/gbfs/1.1/pdx/en/station_status.json")}
49 |
50 | #'
51 | #' @export
52 | get_station_status <- function(city, directory = NULL, file = "station_status.rds", output = NULL) {
53 |
54 | get_gbfs_dataset_(city, directory, file, output, feed = "station_status")
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/man/get_station_information.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_static_feeds.R
3 | \name{get_station_information}
4 | \alias{get_station_information}
5 | \title{Grab the station_information feed.}
6 | \usage{
7 | get_station_information(
8 | city,
9 | directory = NULL,
10 | file = "station_information.rds",
11 | output = NULL
12 | )
13 | }
14 | \arguments{
15 | \item{city}{A character string that can be matched to a gbfs feed. The recommended
16 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
17 | also attempt to match to the URL of an active .json feed or city name.}
18 |
19 | \item{directory}{Optional. Path to a folder (or folder to be
20 | created) where the feed will be saved.}
21 |
22 | \item{file}{Optional. The name of the file to be saved (if \code{output}
23 | is set to \code{"save"} or \code{"both"}), as a character string.
24 | Must end in \code{".rds"}.}
25 |
26 | \item{output}{Optional. The type of output method. If left as default, this
27 | argument is inferred from the \code{directory} argument. If
28 | \code{output = "save"}, the object will be saved as an .rds object at
29 | # the given path. If \code{output = "return"}, the output will be returned
30 | as a dataframe object. Setting \code{output = "both"} will do both.}
31 | }
32 | \value{
33 | The output of this function depends on argument to \code{output}
34 | and \code{directory}. Either a saved .rds object generated from the current
35 | feed, a dataframe object, or both.
36 | }
37 | \description{
38 | \code{get_station_information} grabs and tidies the station_information feed for a given city.
39 | This dataset contains locations, capacity, and other information about bikeshare stations.
40 | Metadata for this dataset can be found at:
41 | \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
42 | }
43 | \examples{
44 | # grab the free bike status feed for portland, oreoon's bikeshare program
45 | \donttest{get_station_information(city =
46 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/station_information.json",
47 | output = "return")}
48 |
49 | }
50 | \seealso{
51 | [get_gbfs()] for a wrapper to call each of the \code{get_feed}
52 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
53 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
54 | are released by a given city.
55 | }
56 |
--------------------------------------------------------------------------------
/man/get_free_bike_status.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_dynamic_feeds.R
3 | \name{get_free_bike_status}
4 | \alias{get_free_bike_status}
5 | \title{Grab the free_bike_status feed.}
6 | \usage{
7 | get_free_bike_status(
8 | city,
9 | directory = NULL,
10 | file = "free_bike_status.rds",
11 | output = NULL
12 | )
13 | }
14 | \arguments{
15 | \item{city}{A character string that can be matched to a gbfs feed. The recommended
16 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
17 | also attempt to match to the URL of an active .json feed or city name.}
18 |
19 | \item{directory}{Optional. Path to a folder (or folder to be
20 | created) where the feed will be saved.}
21 |
22 | \item{file}{Optional. The name of the file to be saved (if \code{output}
23 | is set to \code{"save"} or \code{"both"}), as a character string.
24 | Must end in \code{".rds"}.}
25 |
26 | \item{output}{Optional. The type of output method. If left as default, this
27 | argument is inferred from the \code{directory} argument. If
28 | \code{output = "save"}, the object will be saved as an .rds object at
29 | # the given path. If \code{output = "return"}, the output will be returned
30 | as a dataframe object. Setting \code{output = "both"} will do both.}
31 | }
32 | \value{
33 | The output of this function depends on the argument to \code{output}
34 | and \code{directory}. Either a saved .rds object generated from the current
35 | station_information feed, a dataframe object, or both. If a saved feed of
36 | the same type already exists at the filepath, the feed will be appended to
37 | rather than overwritten.
38 | }
39 | \description{
40 | Grab a dataframe giving the geographic location and other metadata of
41 | bikeshare bikes not parked at bikeshare stations. Metadata for this dataset
42 | can be found at: \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
43 | }
44 | \examples{
45 | # grab the free bike status feed for portland, oregon's bikeshare program
46 | \donttest{get_free_bike_status(city =
47 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/free_bike_status.json",
48 | output = "return")}
49 |
50 | }
51 | \seealso{
52 | [get_gbfs()] for a wrapper to call each of the \code{get_feed}
53 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
54 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
55 | are released by a given city.
56 | }
57 |
--------------------------------------------------------------------------------
/R/gbfs_description.R:
--------------------------------------------------------------------------------
1 | #' Package: gbfs
2 | #'
3 | #' The \code{gbfs} package allows users to query tidy datasets about bikeshare
4 | #' programs around the world by supplying a set of functions to interface with
5 | #' .json feeds following the General Bikeshare Feed Specification, a standard
6 | #' data release format developed by the North American Bikeshare Association.
7 | #'
8 | #' @details
9 | #'
10 | #' The main function exported by this package is \code{get_gbfs()}, which
11 | #' grabs every feed released by a city. Alternatively, the user can just
12 | #' grab information on specific feeds (or groups of feeds).
13 | #'
14 | #' Each of the feeds described below can be queried with the \code{get_suffix()}
15 | #' function, where \code{suffix} is replaced with the name of the relevant feed.
16 | #'
17 | #' Although all of the feeds are livestreamed, only a few of the datasets
18 | #' change often:
19 | #'
20 | #' \describe{
21 | #' \item{\code{station_status:}}{ Supplies the number of available bikes and
22 | #' docks at each station as well as station availability}
23 | #' \item{\code{free_bike_status:}}{ Gives the coordinates and metadata on
24 | #' available bikes that are parked, but not at a station.}
25 | #' }
26 | #'
27 | #' In this package, these two datasets are considered "dynamic", and can be
28 | #' specified as desired datasets by setting `\code{feeds = "dynamic"} in the
29 | #' main wrapper function in the package, \code{get_gbfs}.
30 | #'
31 | #' Much of the data supplied in this specification can be considered static.
32 | #' If you want to grab all of these for a given city, set \code{feeds = "static"}
33 | #' when calling \code{get_gbfs}. Static feeds include:
34 | #'
35 | #' \describe{
36 | #' \item{\code{system_information:}}{ Basic metadata about the bikeshare program}
37 | #' \item{\code{station_information:}}{ Information on the capacity and coordinates of stations}
38 | #' \item{Several optional feeds:}{ \code{system_hours}, \code{system_calendar},
39 | #' \code{system_regions}, \code{system_pricing_plans}, and \code{system_alerts}}
40 | #' }
41 | #'
42 | #'
43 | #' @docType package
44 | #' @name gbfs
45 | #' @importFrom dplyr %>%
46 | "_PACKAGE"
47 |
48 | utils::globalVariables(
49 | c(".", "Location", "Name", "last_reported", "last_updated",
50 | "num_bikes_available", "num_bikes_disabled", "num_docks_available",
51 | "num_docks_disabled", "is_installed", "is_renting", "is_returning",
52 | "station_id", "city", "gbfs_feeds", "name", "type",
53 | "Auto-Discovery URL", "System ID"))
54 |
--------------------------------------------------------------------------------
/man/gbfs.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/gbfs_description.R
3 | \docType{package}
4 | \name{gbfs}
5 | \alias{gbfs-package}
6 | \alias{gbfs}
7 | \title{Package: gbfs}
8 | \description{
9 | The \code{gbfs} package allows users to query tidy datasets about bikeshare
10 | programs around the world by supplying a set of functions to interface with
11 | .json feeds following the General Bikeshare Feed Specification, a standard
12 | data release format developed by the North American Bikeshare Association.
13 | }
14 | \details{
15 | The main function exported by this package is \code{get_gbfs()}, which
16 | grabs every feed released by a city. Alternatively, the user can just
17 | grab information on specific feeds (or groups of feeds).
18 |
19 | Each of the feeds described below can be queried with the \code{get_suffix()}
20 | function, where \code{suffix} is replaced with the name of the relevant feed.
21 |
22 | Although all of the feeds are livestreamed, only a few of the datasets
23 | change often:
24 |
25 | \describe{
26 | \item{\code{station_status:}}{ Supplies the number of available bikes and
27 | docks at each station as well as station availability}
28 | \item{\code{free_bike_status:}}{ Gives the coordinates and metadata on
29 | available bikes that are parked, but not at a station.}
30 | }
31 |
32 | In this package, these two datasets are considered "dynamic", and can be
33 | specified as desired datasets by setting `\code{feeds = "dynamic"} in the
34 | main wrapper function in the package, \code{get_gbfs}.
35 |
36 | Much of the data supplied in this specification can be considered static.
37 | If you want to grab all of these for a given city, set \code{feeds = "static"}
38 | when calling \code{get_gbfs}. Static feeds include:
39 |
40 | \describe{
41 | \item{\code{system_information:}}{ Basic metadata about the bikeshare program}
42 | \item{\code{station_information:}}{ Information on the capacity and coordinates of stations}
43 | \item{Several optional feeds:}{ \code{system_hours}, \code{system_calendar},
44 | \code{system_regions}, \code{system_pricing_plans}, and \code{system_alerts}}
45 | }
46 | }
47 | \seealso{
48 | Useful links:
49 | \itemize{
50 | \item \url{https://github.com/simonpcouch/gbfs}
51 | \item Report bugs at \url{https://github.com/simonpcouch/gbfs/issues}
52 | }
53 |
54 | }
55 | \author{
56 | \strong{Maintainer}: Simon P. Couch \email{simonpatrickcouch@gmail.com}
57 |
58 | Authors:
59 | \itemize{
60 | \item Kaelyn Rosenberg \email{kaerosenberg@gmail.com}
61 | }
62 |
63 | Other contributors:
64 | \itemize{
65 | \item Mark Padgham \email{mark.padgham@email.com} [contributor]
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/man/get_station_status.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_dynamic_feeds.R
3 | \name{get_station_status}
4 | \alias{get_station_status}
5 | \title{Grab the station_status feed.}
6 | \usage{
7 | get_station_status(
8 | city,
9 | directory = NULL,
10 | file = "station_status.rds",
11 | output = NULL
12 | )
13 | }
14 | \arguments{
15 | \item{city}{A character string that can be matched to a gbfs feed. The recommended
16 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
17 | also attempt to match to the URL of an active .json feed or city name.}
18 |
19 | \item{directory}{Optional. Path to a folder (or folder to be
20 | created) where the feed will be saved.}
21 |
22 | \item{file}{Optional. The name of the file to be saved (if \code{output}
23 | is set to \code{"save"} or \code{"both"}), as a character string.
24 | Must end in \code{".rds"}.}
25 |
26 | \item{output}{Optional. The type of output method. If left as default, this
27 | argument is inferred from the \code{directory} argument. If
28 | \code{output = "save"}, the object will be saved as an .rds object at
29 | # the given path. If \code{output = "return"}, the output will be returned
30 | as a dataframe object. Setting \code{output = "both"} will do both.}
31 | }
32 | \value{
33 | The output of this function depends on the argument to \code{output}
34 | and \code{directory}. Either a saved .rds object generated from the current
35 | station_information feed, a dataframe object, or both. If a saved feed of
36 | the same type already exists at the filepath, the feed will be appended to
37 | rather than overwritten.
38 | }
39 | \description{
40 | Grab a dataframe giving the geographic location and other metadata of
41 | bikeshare bikes parked at bikeshare stations. Metadata for this dataset
42 | can be found at: \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
43 | }
44 | \examples{
45 | # we can grab the free bike status feed for portland,
46 | # oregon's bikeshare program in several ways! the most
47 | # straightforward way is just to supply the `city` argument
48 | # as a string:
49 | \donttest{get_station_status(city = "biketown_pdx")}
50 |
51 | # the `city` argument can also be supplied as an
52 | # actual URL to an active .json feed
53 | \donttest{get_station_status(city =
54 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/station_status.json")}
55 |
56 | }
57 | \seealso{
58 | [get_gbfs()] for a wrapper to call each of the \code{get_feed}
59 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
60 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
61 | are released by a given city.
62 | }
63 |
--------------------------------------------------------------------------------
/man/get_system_regions.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_static_feeds.R
3 | \name{get_system_regions}
4 | \alias{get_system_regions}
5 | \title{Grab the system_regions feed.}
6 | \usage{
7 | get_system_regions(
8 | city,
9 | directory = NULL,
10 | file = "system_regions.rds",
11 | output = NULL
12 | )
13 | }
14 | \arguments{
15 | \item{city}{A character string that can be matched to a gbfs feed. The recommended
16 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
17 | also attempt to match to the URL of an active .json feed or city name.}
18 |
19 | \item{directory}{Optional. Path to a folder (or folder to be
20 | created) where the feed will be saved.}
21 |
22 | \item{file}{Optional. The name of the file to be saved (if \code{output}
23 | is set to \code{"save"} or \code{"both"}), as a character string.
24 | Must end in \code{".rds"}.}
25 |
26 | \item{output}{Optional. The type of output method. If left as default, this
27 | argument is inferred from the \code{directory} argument. If
28 | \code{output = "save"}, the object will be saved as an .rds object at
29 | # the given path. If \code{output = "return"}, the output will be returned
30 | as a dataframe object. Setting \code{output = "both"} will do both.}
31 | }
32 | \value{
33 | The output of this function depends on argument to \code{output}
34 | and \code{directory}. Either a saved .rds object generated from the current
35 | feed, a dataframe object, or both.
36 | }
37 | \description{
38 | \code{get_system_regions} grabs and tidies the system_regions feed for
39 | a given city. Metadata for this dataset can be found at:
40 | \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
41 | }
42 | \examples{
43 | # we can grab the system regions feed for portland,
44 | # oregon in one of several ways! first, supply the `city`
45 | # argument as a URL, and save to file by leaving output
46 | # set to it's default. usually, we would supply a character
47 | # string (like "pdx", maybe,) for the `directory` argument
48 | # instead of `tempdir`.
49 | \donttest{get_system_regions(city =
50 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_regions.json",
51 | directory = tempdir())}
52 |
53 | # or, instead, just supply the name of
54 | # the city as a string and return the output
55 | # as a dataframe
56 | \donttest{get_system_regions(city = "biketown_pdx",
57 | output = "return")}
58 | }
59 | \seealso{
60 | [get_gbfs()] for a wrapper to call each of the \code{get_feed}
61 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
62 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
63 | are released by a given city.
64 | }
65 |
--------------------------------------------------------------------------------
/man/get_system_information.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/get_static_feeds.R
3 | \name{get_system_information}
4 | \alias{get_system_information}
5 | \title{Grab the system_information feed.}
6 | \usage{
7 | get_system_information(
8 | city,
9 | directory = NULL,
10 | file = "system_information.rds",
11 | output = NULL
12 | )
13 | }
14 | \arguments{
15 | \item{city}{A character string that can be matched to a gbfs feed. The recommended
16 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
17 | also attempt to match to the URL of an active .json feed or city name.}
18 |
19 | \item{directory}{Optional. Path to a folder (or folder to be
20 | created) where the feed will be saved.}
21 |
22 | \item{file}{Optional. The name of the file to be saved (if \code{output}
23 | is set to \code{"save"} or \code{"both"}), as a character string.
24 | Must end in \code{".rds"}.}
25 |
26 | \item{output}{Optional. The type of output method. If left as default, this
27 | argument is inferred from the \code{directory} argument. If
28 | \code{output = "save"}, the object will be saved as an .rds object at
29 | # the given path. If \code{output = "return"}, the output will be returned
30 | as a dataframe object. Setting \code{output = "both"} will do both.}
31 | }
32 | \value{
33 | The output of this function depends on argument to \code{output}
34 | and \code{directory}. Either a saved .rds object generated from the current
35 | feed, a dataframe object, or both.
36 | }
37 | \description{
38 | \code{get_system_information} grabs and tidies the system_information
39 | feed for a given city. Metadata for this dataset can be found at:
40 | \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
41 | }
42 | \examples{
43 | # we can grab the free bike status feed for portland,
44 | # oregon's bikeshare program in several ways! first, supply the `city`
45 | # argument as a URL, and save to file by leaving output
46 | # set to it's default. usually, we would supply a character
47 | # string (like "pdx", maybe,) for the `directory` argument
48 | # instead of `tempdir`.
49 | \donttest{get_system_information(city =
50 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_information.json",
51 | directory = tempdir())}
52 |
53 | # or, instead, just supply the name of
54 | # the city as a string and return the output as a dataframe
55 | \donttest{get_system_information(city = "biketown_pdx",
56 | output = "return")}
57 | }
58 | \seealso{
59 | [get_gbfs()] for a wrapper to call each of the \code{get_feed}
60 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
61 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
62 | are released by a given city.
63 | }
64 |
--------------------------------------------------------------------------------
/docs/jquery.sticky-kit.min.js:
--------------------------------------------------------------------------------
1 | /* Sticky-kit v1.1.2 | WTFPL | Leaf Corcoran 2015 | */
2 | /*
3 | Source: https://github.com/leafo/sticky-kit
4 | License: MIT
5 | */
6 | (function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k));
7 | if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b("
A data.frame of all cities issuing GBFS feeds. The `Auto-Discovery URL`
67 | column supplies the relevant .json feeds, while the entries in the `URL` column
68 | take the user to the public-facing webpage of the programs.
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
52 |
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
53 |
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
54 |
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, issues, and other contributions that are not aligned to this Code of Conduct.
55 |
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/R/get_gbfs.R:
--------------------------------------------------------------------------------
1 | #' Get table of all cities releasing GBFS feeds
2 | #'
3 | #' @return A \code{data.frame} of all cities issuing GBFS feeds. The `Auto-Discovery URL`
4 | #' column supplies the relevant .json feeds, while the entries in the `URL` column
5 | #' take the user to the public-facing webpage of the programs.
6 | #' @source North American Bikeshare Association, General Bikeshare Feed Specification
7 | #' \url{https://raw.githubusercontent.com/MobilityData/gbfs/master/systems.csv}
8 | #' @export
9 | get_gbfs_cities <- function() {
10 |
11 | # test internet connection
12 | if (!connected_to_internet()) {
13 | return(message_no_internet())
14 | }
15 |
16 | # specify column types
17 | systems_cols <- readr::cols(
18 | `Country Code` = readr::col_character(),
19 | "Name" = readr::col_character(),
20 | "Location" = readr::col_character(),
21 | `System ID` = readr::col_character(),
22 | `URL` = readr::col_character(),
23 | `Auto-Discovery URL` = readr::col_character()
24 | )
25 |
26 | # grab the data
27 | readr::read_csv("https://raw.githubusercontent.com/MobilityData/gbfs/master/systems.csv",
28 | col_types = systems_cols)
29 | }
30 |
31 |
32 |
33 | #' Get dataframe of bikeshare feeds released by a city
34 | #'
35 | #' @description Of the different types of feeds supplied by the gbfs,
36 | #' some are required, some are conditionally required, and some are
37 | #' optional. This function grabs a list of each of the feeds supplied
38 | #' by a given city, as well as the URLs to access them.
39 | #'
40 | #' @param city A character string that can be matched to a gbfs feed. The recommended
41 | #' argument is a system ID supplied in the output of [get_gbfs_cities()], but will
42 | #' also attempt to match to the URL of an active .json feed or city name.
43 | #'
44 | #' @return A \code{data.frame} containing the feeds supplied by
45 | #' a city. . The `feed` column supplies the name of the relevant .json feeds,
46 | #' while the entries in the `URL` column supply the feeds themselves.
47 | #'
48 | #' @source North American Bikeshare Association, General Bikeshare Feed
49 | #' Specification \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
50 | #'
51 | #' @examples
52 | #' # grab all of the feeds released by portland
53 | #' \donttest{get_which_gbfs_feeds(city = "biketown_pdx")}
54 | #'
55 | #' @export
56 | get_which_gbfs_feeds <- function(city) {
57 |
58 | # test internet connection
59 | if (!connected_to_internet()) {
60 | return(message_no_internet())
61 | }
62 |
63 | # convert the city argument to a URL
64 | url <- city_to_url(city, "gbfs")
65 |
66 | # grab the relevant data
67 | gbfs <- tryCatch(jsonlite::fromJSON(txt = url),
68 | error = report_connection_issue)
69 |
70 | # pull out the dataset
71 | gbfs_feeds <- gbfs[["data"]][[1]][[1]]
72 |
73 | # ...and return it!
74 | return(gbfs_feeds)
75 |
76 | }
77 |
78 | #' Grab bikeshare data
79 | #'
80 | #' \code{get_gbfs} grabs bikeshare data supplied in the General Bikeshare
81 | #' Feed Specification format for a given city. By default, the function returns
82 | #' the results as a named list of dataframes, but to make accumulation of
83 | #' datasets over time straightforward, the user can also save the results
84 | #' as .Rds files that will be automatically row-binded.
85 | #' Metadata for each dataset can be found at:
86 | #' \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
87 | #'
88 | #' @param city A character string that can be matched to a city or a url to an
89 | #' active gbfs.json feed. See \code{get_gbfs_cities} for a current list of available cities.
90 | #' @param feeds Optional. A character string specifying which feeds should be saved.
91 | #' Options are \code{"all"}, \code{"static"}, and \code{"dynamic"}.
92 | #' @param directory Optional. Path to a folder (or folder to be created) where
93 | #' the feed will will be saved.
94 | #' @param output Optional. The type of output method. By default, output method
95 | #' will be inferred from the \code{directory} argument. If \code{output = "save"},
96 | #' the dataframes will be saved as .rds objects in the given folder. If
97 | #' \code{output = "return"}, the results will be returned as a named list of
98 | #' dataframes. Setting \code{output = "both"} will do both. If both are left
99 | #' as NULL, the result will be returned and not saved to file.
100 | #' @return The output of this function depends on the arguments supplied to
101 | #' \code{output} and \code{directory}. Either a folder of .rds dataframes saved
102 | #' at the given path, a returned named list of dataframes, or both.
103 | #' The function will raise an error if the \code{directory} and \code{output}
104 | #' arguments seem to conflict.
105 | #' @examples
106 | #' # grab all of the feeds released by portland's
107 | #' # bikeshare program and return them as a
108 | #' # named list of dataframes
109 | #' \donttest{get_gbfs(city = "biketown_pdx")}
110 | #'
111 | #' # if, rather than returning the data, we wanted to save it:
112 | #' \donttest{get_gbfs(city = "biketown_pdx", directory = tempdir())}
113 | #'
114 | #' # note that, usually, we'd supply a character string
115 | #' # (like "pdx", maybe,) to the directory argument
116 | #' # instead of `tempdir()`.
117 | #'
118 | #' # if we're having trouble specifying the correct feed,
119 | #' # we can also supply the actual URL to the feed
120 | #' \donttest{get_gbfs(city = "https://gbfs.lyft.com/gbfs/1.1/pdx/gbfs.json")}
121 | #'
122 | #' # the examples above grab every feed that portland releases.
123 | #' # if, instead, we just wanted the dynamic feeds
124 | #' \donttest{get_gbfs(city = "biketown_pdx", feeds = "dynamic")}
125 | #' @export
126 | get_gbfs <- function(city, feeds = "all", directory = NULL, output = NULL) {
127 |
128 | # test internet connection
129 | if (!connected_to_internet()) {
130 | return(message_no_internet())
131 | }
132 |
133 | # check the "feeds" argument
134 | feeds <- process_feeds_argument(feeds)
135 |
136 | # figure out how to output the resulting object
137 | output_types <- determine_output_types(directory, output)
138 |
139 | # check that, if the user said to save the file, they also
140 | # supplied a directory
141 | if (output_types[1] & is.null(directory)) {
142 | stop(sprintf(c("The argument to output suggests that the resulting",
143 | " data should be saved, but a directory to save the",
144 | " outputs in hasn't been supplied. Please supply",
145 | " an argument to directory or leave the output argument",
146 | " as default.")))
147 | }
148 |
149 | # convert the city argument to a top-level gbfs url
150 | url <- city_to_url(city, "gbfs")
151 |
152 | # figure out which feeds are available
153 | available_feeds <- get_which_gbfs_feeds(city = url)
154 |
155 | # ...and then figure out which of them to grab
156 | relevant_feeds <- available_feeds %>%
157 | dplyr::left_join(all_feeds, by = "name") %>%
158 | dplyr::filter(type %in% feeds) %>%
159 | dplyr::select(name) %>%
160 | dplyr::pull()
161 |
162 | # grab all of the relevant feeds! note that this will save each
163 | # of the datasets in the directory folder if directory is
164 | # something other than NULL
165 | data <- suppressMessages(
166 | purrr::map2(paste0(relevant_feeds, ".Rds"),
167 | relevant_feeds,
168 | get_gbfs_dataset_,
169 | city = url,
170 | directory = directory,
171 | output = NULL)
172 | )
173 |
174 | # name each of the elements so that they're more easily accessible
175 | names(data) <- relevant_feeds
176 |
177 | # output the datasets as desired :-)
178 | if (output_types[2]) {
179 | return(data)
180 | }
181 | }
182 |
183 |
--------------------------------------------------------------------------------
/README.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | output: github_document
3 | ---
4 |
5 | ```{r, echo = FALSE, message = FALSE}
6 | knitr::opts_chunk$set(
7 | collapse = TRUE,
8 | comment = "#>",
9 | fig.path = "figures/"
10 | )
11 | devtools::load_all()
12 | ```
13 |
14 | # General Bikeshare Feed Specification
15 |
16 | [](https://cran.r-project.org/package=gbfs)
17 | [](https://github.com/simonpcouch/gbfs/actions)
18 | [](https://cran.r-project.org/package=gbfs)
19 |
20 | The `gbfs` package supplies a set of functions to interface with General
21 | Bikeshare Feed Specification .json feeds in R, allowing users to save
22 | and accumulate tidy .rds datasets for specified cities/bikeshare programs.
23 | The North American Bikeshare Association's [gbfs](https://github.com/MobilityData/gbfs)
24 | is a standardized data release format for live information on the status
25 | of bikeshare programs, as well as metadata, including counts of bikes at
26 | stations, ridership costs, and geographic locations of stations and
27 | parked bikes.
28 |
29 | __Features__
30 |
31 | * Get bikeshare data by specifying city name or supplying url of feed
32 | * All feeds for a city can be saved with a single function
33 | * New information from dynamic feeds can be appended to existing datasets
34 |
35 | ## Installation
36 |
37 | We're on CRAN! Install the latest release with:
38 |
39 | ```{r cran-installation, eval = FALSE}
40 | install.packages("gbfs")
41 | library(gbfs)
42 | ```
43 |
44 | You can install the developmental version of `gbfs` from GitHub with:
45 |
46 | ```{r gh-installation, eval = FALSE}
47 | # install.packages("devtools")
48 | devtools::install_github("simonpcouch/gbfs")
49 | ```
50 |
51 | ## Background
52 |
53 | The `gbfs` is a standardized data feed describing the current status of a
54 | bikeshare program.
55 |
56 | Although all of the data is live, only a few of the datasets change often:
57 |
58 | * `station_status`: Supplies the number of available bikes and
59 | docks at each station as well as station availability
60 | * `free_bike_status`: Gives the coordinates and metadata on available
61 | bikes that are parked, but not at a station.
62 |
63 | In this package, these two datasets are considered "dynamic", and can be
64 | specified as desired datasets by setting `feeds = "dynamic"` in the
65 | main wrapper function in the package, `get_gbfs`.
66 |
67 | Much of the data supplied in this specification can be considered static. If you
68 | want to grab all of these for a given city, set `feeds = "static"` when calling
69 | `get_gbfs`. Static feeds include:
70 |
71 | * `system_information`: Basic metadata about the bikeshare program
72 | * `station_information`: Information on the capacity and coordinates of stations
73 | * Several optional feeds: `system_hours`, `system_calendar`, `system_regions`,
74 | `system_pricing_plans`, and `system_alerts`
75 |
76 | Each of the above feeds can be queried with the `get_suffix` function, where
77 | `suffix` is replaced with the name of the relevant feed.
78 |
79 | For more details on the official `gbfs` spec, see
80 | [this document](https://github.com/MobilityData/gbfs/blob/master/gbfs.md).
81 |
82 | ## Example
83 |
84 | In this example, we'll grab data from Portland, Oregon's Biketown bikeshare
85 | program and visualize some of the different datasets.
86 |
87 | ```{r, warning = FALSE, message = FALSE}
88 | # load necessary packages
89 | library(tidyverse)
90 | ```
91 |
92 |
93 | First, we'll grab some information on the stations.
94 |
95 | ```{r}
96 | # grab portland station information and return it as a dataframe
97 | pdx_station_info <-
98 | get_station_information("https://gbfs.lyft.com/gbfs/1.1/pdx/gbfs.json")
99 |
100 | # check it out!
101 | glimpse(pdx_station_info)
102 | ```
103 |
104 | ...as well as the number of bikes at each station.
105 |
106 | ```{r}
107 | # grab current capacity at each station and return it as a dataframe
108 | pdx_station_status <-
109 | get_station_status("https://gbfs.lyft.com/gbfs/1.1/pdx/gbfs.json")
110 |
111 | # check it out!
112 | glimpse(pdx_station_status)
113 | ```
114 |
115 | Just like that, we have two tidy datasets containing information about
116 | Portland's bikeshare program.
117 |
118 | Joining these datasets, we can get the capacity at each station, along with each
119 | station's metadata.
120 |
121 | ```{r}
122 | # full join these two datasets on station_id and select a few columns
123 | pdx_stations <- full_join(pdx_station_info,
124 | pdx_station_status,
125 | by = "station_id") %>%
126 | # just select columns we're interested in visualizing
127 | select(id = station_id,
128 | lon,
129 | lat,
130 | num_bikes_available,
131 | num_docks_available) %>%
132 | mutate(type = "docked")
133 | ```
134 |
135 | Finally, before we plot, lets grab the locations of the bikes parked in
136 | Portland that are not docked at a station,
137 |
138 | ```{r}
139 | # grab data on free bike status and save it as a dataframe
140 | pdx_free_bikes <-
141 | get_free_bike_status("https://gbfs.lyft.com/gbfs/1.1/pdx/gbfs.json",
142 | output = "return") %>%
143 | # just select columns we're interested in visualizing
144 | select(id = bike_id, lon, lat) %>%
145 | # make columns analogous to station_status for row binding
146 | mutate(num_bikes_available = 1,
147 | num_docks_available = NA,
148 | type = "free")
149 | ```
150 |
151 | ...and bind these dataframes together!
152 |
153 | ```{r}
154 | # row bind stationed and free bike info
155 | pdx_full <- bind_rows(pdx_stations, pdx_free_bikes)
156 | ```
157 |
158 | Now, plotting,
159 |
160 | ```{r plot}
161 | # filter out stations with 0 available bikes
162 | pdx_plot <- pdx_full %>%
163 | filter(num_bikes_available > 0) %>%
164 | # plot the geospatial distribution of bike counts
165 | ggplot() +
166 | aes(x = lon,
167 | y = lat,
168 | size = num_bikes_available,
169 | col = type) +
170 | geom_point() +
171 | # make aesthetics slightly more cozy
172 | theme_minimal() +
173 | scale_color_brewer(type = "qual")
174 | ```
175 |
176 | ```{r print-plot, eval = FALSE}
177 | pdx_plot
178 | ```
179 |
180 |
181 |
182 | Folks who have spent a significant amount of time in Portland might be able to
183 | pick out the Willamette River running Northwest/Southeast through the city.
184 | With a few lines of `gbfs`, `dplyr`, and `ggplot2`, we can put together a
185 | meaningful visualization to help us better understand how bikeshare bikes
186 | are distributed throughout Portland.
187 |
188 | Some other features worth playing around with in `gbfs` that weren't touched
189 | on in this example:
190 |
191 | * The main wrapper function in the package, `get_gbfs`, will grab every
192 | dataset for a given city. (We call the functions to grab individual datasets
193 | above for clarity.)
194 | * In the above lines, we output the datasets as returned dataframes. If you'd
195 | rather save the output to your local files, check out the `directory` and
196 | `return` arguments.
197 | * When the `output` argument is left as default in `get_free_bike_status` and
198 | `get_station_status` (the functions for the `dynamic` dataframes,)
199 | and a dataframe already exists at the given path, `gbfs` will row bind the
200 | dataframes, allowing for the capability to accumulate large datasets over time.
201 | * If you're not sure if your city supplies `gbfs` feeds, you might find the
202 | `get_gbfs_cities` and `get_which_gbfs_feeds` functions useful.
203 |
204 | ## Contributing
205 |
206 | Please note that the `gbfs` R package is released with a [Contributor Code of Conduct](CONTRIBUTING.md). By contributing to this project, you agree to abide by its terms.
207 |
--------------------------------------------------------------------------------
/R/get_static_feeds.R:
--------------------------------------------------------------------------------
1 | #' Grab the station_information feed.
2 | #'
3 | #' \code{get_station_information} grabs and tidies the station_information feed for a given city.
4 | #' This dataset contains locations, capacity, and other information about bikeshare stations.
5 | #' Metadata for this dataset can be found at:
6 | #' \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
7 | #'
8 | #' @param city A character string that can be matched to a gbfs feed. The recommended
9 | #' argument is a system ID supplied in the output of [get_gbfs_cities()], but will
10 | #' also attempt to match to the URL of an active .json feed or city name.
11 | #' @param directory Optional. Path to a folder (or folder to be
12 | #' created) where the feed will be saved.
13 | #' @param file Optional. The name of the file to be saved (if \code{output}
14 | #' is set to \code{"save"} or \code{"both"}), as a character string.
15 | #' Must end in \code{".rds"}.
16 | #' @param output Optional. The type of output method. If left as default, this
17 | #' argument is inferred from the \code{directory} argument. If
18 | #' \code{output = "save"}, the object will be saved as an .rds object at
19 | #' # the given path. If \code{output = "return"}, the output will be returned
20 | #' as a dataframe object. Setting \code{output = "both"} will do both.
21 | #'
22 | #' @return The output of this function depends on argument to \code{output}
23 | #' and \code{directory}. Either a saved .rds object generated from the current
24 | #' feed, a dataframe object, or both.
25 | #'
26 | #' @seealso [get_gbfs()] for a wrapper to call each of the \code{get_feed}
27 | #' functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
28 | #' functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
29 | #' are released by a given city.
30 | #'
31 | #' @examples
32 | #' # grab the free bike status feed for portland, oreoon's bikeshare program
33 | #' \donttest{get_station_information(city =
34 | #' "https://gbfs.lyft.com/gbfs/1.1/pdx/en/station_information.json",
35 | #' output = "return")}
36 | #'
37 | #' @export
38 | get_station_information <- function(city, directory = NULL, file = "station_information.rds", output = NULL) {
39 |
40 | get_gbfs_dataset_(city, directory, file, output, feed = "station_information")
41 |
42 | }
43 |
44 | #' Grab the system_alerts feed.
45 | #'
46 | #' \code{get_system_alerts} grabs and tidies the system_alerts feed for a given city.
47 | #' This feed informs users about changes to normal operation. Metadata for this
48 | #' dataset can be found at: \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
49 | #'
50 | #' @inherit get_station_information params return seealso
51 | #'
52 | #' @examples
53 | #' # grab the system alerts feed for portland, oregon
54 | #' \donttest{get_system_alerts(city =
55 | #' "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_alerts.json",
56 | #' output = "return")}
57 | #'
58 | #' @export
59 |
60 | get_system_alerts <- function (city, directory = NULL, file = "system_alerts.rds", output = NULL) {
61 |
62 | get_gbfs_dataset_(city, directory, file, output, feed = "system_alerts")
63 |
64 | }
65 |
66 | #' Grab the system_calendar feed.
67 | #'
68 | #' \code{get_system_calendar} grabs and tidies the system_calendar feed
69 | #' for a given city. Metadata for this dataset can be found at:
70 | #' \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
71 | #'
72 | #' @inherit get_station_information params return seealso
73 | #'
74 | #' @examples
75 | #' # grab the system calendar feed for portland, oregon
76 | #' \donttest{get_system_calendar(city =
77 | #' "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_calendar.json",
78 | #' output = "return")}
79 | #'
80 | #'
81 | #' @export
82 |
83 | get_system_calendar <- function (city, directory = NULL, file = "system_calendar.rds", output = NULL) {
84 |
85 | get_gbfs_dataset_(city, directory, file, output, feed = "system_calendar")
86 |
87 | }
88 |
89 | #' Grab the system_hours feed.
90 | #'
91 | #' \code{get_system_hours} grabs and tidies the system_hours
92 | #' feed for a given city. Metadata for this
93 | #' dataset can be found at:
94 | #' \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
95 | #'
96 | #' @inherit get_station_information params return seealso
97 | #'
98 | #' @examples
99 | #' # grab the system hours feed for portland, oregon
100 | #' \donttest{get_system_hours(city =
101 | #' "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_hours.json",
102 | #' output = "return")}
103 | #'
104 | #' @export
105 |
106 | get_system_hours <- function (city, directory = NULL, file = "system_hours.rds", output = NULL) {
107 |
108 | get_gbfs_dataset_(city, directory, file, output, feed = "system_hours")
109 |
110 | }
111 |
112 | #' Grab the system_information feed.
113 | #'
114 | #' \code{get_system_information} grabs and tidies the system_information
115 | #' feed for a given city. Metadata for this dataset can be found at:
116 | #' \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
117 | #'
118 | #' @inherit get_station_information params return seealso
119 | #'
120 | #' @examples
121 | #' # we can grab the free bike status feed for portland,
122 | #' # oregon's bikeshare program in several ways! first, supply the `city`
123 | #' # argument as a URL, and save to file by leaving output
124 | #' # set to it's default. usually, we would supply a character
125 | #' # string (like "pdx", maybe,) for the `directory` argument
126 | #' # instead of `tempdir`.
127 | #' \donttest{get_system_information(city =
128 | #' "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_information.json",
129 | #' directory = tempdir())}
130 | #'
131 | #' # or, instead, just supply the name of
132 | #' # the city as a string and return the output as a dataframe
133 | #'\donttest{get_system_information(city = "biketown_pdx",
134 | #' output = "return")}
135 | #' @export
136 |
137 | get_system_information <- function(city, directory = NULL, file = "system_information.rds", output = NULL){
138 |
139 | get_gbfs_dataset_(city, directory, file, output, feed = "system_information")
140 |
141 | }
142 |
143 | #' Grab the system_pricing_plans feed.
144 | #'
145 | #' \code{get_system_pricing_plans} grabs and tidies the system_pricing_plans
146 | #' feed for a given city. Metadata for this dataset can be found at:
147 | #' \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
148 | #'
149 | #' @inherit get_station_information params return seealso
150 | #'
151 | #' @export
152 |
153 | get_system_pricing_plans <- function(city, directory = NULL, file = "system_pricing_plans.rds", output = NULL) {
154 |
155 | get_gbfs_dataset_(city, directory, file, output, feed = "system_pricing_plans")
156 |
157 | }
158 |
159 | #' Grab the system_regions feed.
160 | #'
161 | #' \code{get_system_regions} grabs and tidies the system_regions feed for
162 | #' a given city. Metadata for this dataset can be found at:
163 | #' \url{https://github.com/MobilityData/gbfs/blob/master/gbfs.md}
164 | #'
165 | #' @inherit get_station_information params return seealso
166 | #'
167 | #' @examples
168 | #' # we can grab the system regions feed for portland,
169 | #' # oregon in one of several ways! first, supply the `city`
170 | #' # argument as a URL, and save to file by leaving output
171 | #' # set to it's default. usually, we would supply a character
172 | #' # string (like "pdx", maybe,) for the `directory` argument
173 | #' # instead of `tempdir`.
174 | #' \donttest{get_system_regions(city =
175 | #' "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_regions.json",
176 | #' directory = tempdir())}
177 | #'
178 | #' # or, instead, just supply the name of
179 | #' # the city as a string and return the output
180 | #' # as a dataframe
181 | #'\donttest{get_system_regions(city = "biketown_pdx",
182 | #' output = "return")}
183 | #' @export
184 | get_system_regions <- function(city, directory = NULL, file = "system_regions.rds", output = NULL) {
185 |
186 | get_gbfs_dataset_(city, directory, file, output, feed = "system_regions")
187 |
188 | }
189 |
--------------------------------------------------------------------------------
/docs/reference/index.html:
--------------------------------------------------------------------------------
1 |
2 | Package index • gbfs
6 |
7 |
8 |
A character string that can be matched to a gbfs feed. The recommended
74 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
75 | also attempt to match to the URL of an active .json feed or city name.
76 |
77 |
78 |
directory
79 |
Optional. Path to a folder (or folder to be
80 | created) where the feed will be saved.
81 |
82 |
83 |
file
84 |
Optional. The name of the file to be saved (if output
85 | is set to "save" or "both"), as a character string.
86 | Must end in ".rds".
87 |
88 |
89 |
output
90 |
Optional. The type of output method. If left as default, this
91 | argument is inferred from the directory argument. If
92 | output = "save", the object will be saved as an .rds object at
93 | # the given path. If output = "return", the output will be returned
94 | as a dataframe object. Setting output = "both" will do both.
95 |
96 |
97 |
98 |
Value
99 |
The output of this function depends on argument to output
100 | and directory. Either a saved .rds object generated from the current
101 | feed, a dataframe object, or both.
102 |
103 |
104 |
See also
105 |
[get_gbfs()] for a wrapper to call each of the get_feed
106 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
107 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
108 | are released by a given city.
The gbfs package allows users to query tidy datasets about bikeshare
56 | programs around the world by supplying a set of functions to interface with
57 | .json feeds following the General Bikeshare Feed Specification, a standard
58 | data release format developed by the North American Bikeshare Association.
59 |
60 |
61 |
62 |
63 |
Details
64 |
The main function exported by this package is get_gbfs(), which
65 | grabs every feed released by a city. Alternatively, the user can just
66 | grab information on specific feeds (or groups of feeds).
67 |
Each of the feeds described below can be queried with the get_suffix()
68 | function, where suffix is replaced with the name of the relevant feed.
69 |
Although all of the feeds are livestreamed, only a few of the datasets
70 | change often:
71 |
station_status:
72 |
Supplies the number of available bikes and
73 | docks at each station as well as station availability
74 |
75 |
free_bike_status:
76 |
Gives the coordinates and metadata on
77 | available bikes that are parked, but not at a station.
78 |
79 |
80 |
In this package, these two datasets are considered "dynamic", and can be
81 | specified as desired datasets by setting `feeds = "dynamic" in the
82 | main wrapper function in the package, get_gbfs.
83 |
Much of the data supplied in this specification can be considered static.
84 | If you want to grab all of these for a given city, set feeds = "static"
85 | when calling get_gbfs. Static feeds include:
86 |
system_information:
87 |
Basic metadata about the bikeshare program
88 |
89 |
station_information:
90 |
Information on the capacity and coordinates of stations
91 |
92 |
Several optional feeds:
93 |
system_hours, system_calendar,
94 | system_regions, system_pricing_plans, and system_alerts
A character string that can be matched to a gbfs feed. The recommended
76 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
77 | also attempt to match to the URL of an active .json feed or city name.
78 |
79 |
80 |
directory
81 |
Optional. Path to a folder (or folder to be
82 | created) where the feed will be saved.
83 |
84 |
85 |
file
86 |
Optional. The name of the file to be saved (if output
87 | is set to "save" or "both"), as a character string.
88 | Must end in ".rds".
89 |
90 |
91 |
output
92 |
Optional. The type of output method. If left as default, this
93 | argument is inferred from the directory argument. If
94 | output = "save", the object will be saved as an .rds object at
95 | # the given path. If output = "return", the output will be returned
96 | as a dataframe object. Setting output = "both" will do both.
97 |
98 |
99 |
100 |
Value
101 |
The output of this function depends on argument to output
102 | and directory. Either a saved .rds object generated from the current
103 | feed, a dataframe object, or both.
104 |
105 |
106 |
See also
107 |
[get_gbfs()] for a wrapper to call each of the get_feed
108 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
109 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
110 | are released by a given city.
111 |
112 |
113 |
114 |
Examples
115 |
# grab the system hours feed for portland, oregon
116 | get_system_hours(city =
117 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_hours.json",
118 | output ="return")
119 | #> data frame with 0 columns and 0 rows
120 |
121 |
get_system_alerts grabs and tidies the system_alerts feed for a given city.
55 | This feed informs users about changes to normal operation. Metadata for this
56 | dataset can be found at: https://github.com/MobilityData/gbfs/blob/master/gbfs.md
A character string that can be matched to a gbfs feed. The recommended
74 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
75 | also attempt to match to the URL of an active .json feed or city name.
76 |
77 |
78 |
directory
79 |
Optional. Path to a folder (or folder to be
80 | created) where the feed will be saved.
81 |
82 |
83 |
file
84 |
Optional. The name of the file to be saved (if output
85 | is set to "save" or "both"), as a character string.
86 | Must end in ".rds".
87 |
88 |
89 |
output
90 |
Optional. The type of output method. If left as default, this
91 | argument is inferred from the directory argument. If
92 | output = "save", the object will be saved as an .rds object at
93 | # the given path. If output = "return", the output will be returned
94 | as a dataframe object. Setting output = "both" will do both.
95 |
96 |
97 |
98 |
Value
99 |
The output of this function depends on argument to output
100 | and directory. Either a saved .rds object generated from the current
101 | feed, a dataframe object, or both.
102 |
103 |
104 |
See also
105 |
[get_gbfs()] for a wrapper to call each of the get_feed
106 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
107 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
108 | are released by a given city.
109 |
110 |
111 |
112 |
Examples
113 |
# grab the system alerts feed for portland, oregon
114 | get_system_alerts(city =
115 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_alerts.json",
116 | output ="return")
117 | #> data frame with 0 columns and 0 rows
118 |
119 |
A character string that can be matched to a gbfs feed. The recommended
74 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
75 | also attempt to match to the URL of an active .json feed or city name.
76 |
77 |
78 |
directory
79 |
Optional. Path to a folder (or folder to be
80 | created) where the feed will be saved.
81 |
82 |
83 |
file
84 |
Optional. The name of the file to be saved (if output
85 | is set to "save" or "both"), as a character string.
86 | Must end in ".rds".
87 |
88 |
89 |
output
90 |
Optional. The type of output method. If left as default, this
91 | argument is inferred from the directory argument. If
92 | output = "save", the object will be saved as an .rds object at
93 | # the given path. If output = "return", the output will be returned
94 | as a dataframe object. Setting output = "both" will do both.
95 |
96 |
97 |
98 |
Value
99 |
The output of this function depends on argument to output
100 | and directory. Either a saved .rds object generated from the current
101 | feed, a dataframe object, or both.
102 |
103 |
104 |
See also
105 |
[get_gbfs()] for a wrapper to call each of the get_feed
106 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
107 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
108 | are released by a given city.
Of the different types of feeds supplied by the gbfs,
56 | some are required, some are conditionally required, and some are
57 | optional. This function grabs a list of each of the feeds supplied
58 | by a given city, as well as the URLs to access them.
A character string that can be matched to a gbfs feed. The recommended
76 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
77 | also attempt to match to the URL of an active .json feed or city name.
78 |
79 |
80 |
81 |
Value
82 |
A data.frame containing the feeds supplied by
83 | a city. . The `feed` column supplies the name of the relevant .json feeds,
84 | while the entries in the `URL` column supply the feeds themselves.
A character string that can be matched to a gbfs feed. The recommended
74 | argument is a system ID supplied in the output of [get_gbfs_cities()], but will
75 | also attempt to match to the URL of an active .json feed or city name.
76 |
77 |
78 |
directory
79 |
Optional. Path to a folder (or folder to be
80 | created) where the feed will be saved.
81 |
82 |
83 |
file
84 |
Optional. The name of the file to be saved (if output
85 | is set to "save" or "both"), as a character string.
86 | Must end in ".rds".
87 |
88 |
89 |
output
90 |
Optional. The type of output method. If left as default, this
91 | argument is inferred from the directory argument. If
92 | output = "save", the object will be saved as an .rds object at
93 | # the given path. If output = "return", the output will be returned
94 | as a dataframe object. Setting output = "both" will do both.
95 |
96 |
97 |
98 |
Value
99 |
The output of this function depends on argument to output
100 | and directory. Either a saved .rds object generated from the current
101 | feed, a dataframe object, or both.
102 |
103 |
104 |
See also
105 |
[get_gbfs()] for a wrapper to call each of the get_feed
106 | functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs
107 | functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds
108 | are released by a given city.
109 |
110 |
111 |
112 |
Examples
113 |
# we can grab the system regions feed for portland,
114 | # oregon in one of several ways! first, supply the `city`
115 | # argument as a URL, and save to file by leaving output
116 | # set to it's default. usually, we would supply a character
117 | # string (like "pdx", maybe,) for the `directory` argument
118 | # instead of `tempdir`.
119 | get_system_regions(city =
120 | "https://gbfs.lyft.com/gbfs/1.1/pdx/en/system_regions.json",
121 | directory =tempdir())
122 |
123 | # or, instead, just supply the name of
124 | # the city as a string and return the output
125 | # as a dataframe
126 | get_system_regions(city ="biketown_pdx",
127 | output ="return")
128 | #> name region_id
129 | #> 1 PDX PDX
130 |