Learn R Programming

gbfs (version 1.3.0)

get_free_bike_status: Grab the free_bike_status feed.

Description

Grab a dataframe giving the geographic location and other metadata of bikeshare bikes not parked at bikeshare stations. Metadata for this dataset can be found at: https://github.com/NABSA/gbfs/blob/master/gbfs.md

Usage

get_free_bike_status(
  city,
  directory = NULL,
  file = "free_bike_status.rds",
  output = NULL
)

Arguments

city

A character string that can be matched to a city or a url to an active gbfs .json feed. See [get_gbfs_cities()] for a current list of available cities.

directory

Optional. Path to a folder (or folder to be created) where the feed will be saved.

file

Optional. The name of the file to be saved (if output is set to "save" or "both"), as a character string. Must end in ".rds".

output

Optional. The type of output method. If left as default, this argument is inferred from the directory argument. If output = "save", the object will be saved as an .rds object at # the given path. If output = "return", the output will be returned as a dataframe object. Setting output = "both" will do both.

Value

The output of this function depends on the argument to output and directory. Either a saved .rds object generated from the current station_information feed, a dataframe object, or both. If a saved feed of the same type already exists at the filepath, the feed will be appended to rather than overwritten.

See Also

[get_gbfs()] for a wrapper to call each of the get_feed functions, [get_gbfs_cities()] for a dataframe of cities releasing gbfs functions, and [get_which_gbfs_feeds()] for a dataframe of which feeds are released by a given city.

Examples

Run this code
# NOT RUN {
# we can grab the free bike status feed for portland, 
# oregon's bikeshare program in  several ways! the most 
# straightforward way is just to supply the `city` argument
# as a string:
# }
# NOT RUN {
get_free_bike_status(city = "portland")
# }
# NOT RUN {
# the `city` argument can also be supplied as an
# actual URL to an active .json feed
# }
# NOT RUN {
get_free_bike_status(city = 
"http://biketownpdx.socialbicycles.com/opendata/free_bike_status.json",  
                     directory = tempdir())
# }
# NOT RUN {
# if you'd like to save the output to file, supply a 
# `directory` argument. usually, though, we would supply a 
# character string (like "pdx", maybe,) for the `directory` 
# argument instead of `tempdir`.
# }
# NOT RUN {
get_free_bike_status(city = "portland",  
                     directory = tempdir())
# }
# NOT RUN {
                     
# the output argument can control whether the file is
# saved and/or returned explicitly
# }
# NOT RUN {
get_free_bike_status(city = "portland",  
                     directory = tempdir(),
                     output = "both")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab