Learn R Programming

gbfs (version 1.3.0)

get_system_alerts: Grab the system_alerts feed.

Description

get_system_alerts grabs and tidies the system_alerts feed for a given city. This feed informs users about changes to normal operation. Metadata for this dataset can be found at: https://github.com/NABSA/gbfs/blob/master/gbfs.md

Usage

get_system_alerts(
  city,
  directory = NULL,
  file = "system_alerts.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 argument to output and directory. Either a saved .rds object generated from the current feed, a dataframe object, or both.

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 system alerts feed for portland, 
# oregon in one of several ways! first, supply the `city` 
# argument as a URL, and save to file by leaving output 
# set to it's default. usually, we would supply a character 
# string (like "pdx", maybe,) for the `directory` argument 
# instead of `tempdir`.
# }
# NOT RUN {
get_system_alerts(city = 
"http://biketownpdx.socialbicycles.com/opendata/system_alerts.json",  
                  directory = tempdir())
# }
# NOT RUN {
                    
# or, instead, just supply the name of 
# the city as a string. 
# }
# NOT RUN {
get_system_alerts(city = "portland",
                  directory = tempdir())
# }
# NOT RUN {
                    
# instead of saving the output as a file, we can 
# just return the output as a dataframe
# }
# NOT RUN {
get_system_alerts(city = "portland",  
                  output = "return")
# }
# NOT RUN {
 
                  
# }

Run the code above in your browser using DataLab