gss_timeline: Function to query and plot the history of changes to a single...

Description Usage Arguments Details Value Examples

View source: R/gss_timeline.R

Description

The function draws a timeline of changes to the gss_code or whole resolution; it doesn't describe the changes (yet).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
gss_timeline(
  resolution = c("OA", "LSOA", "MSOA", "WARD", "LAD"),
  gss_codes = NULL,
  startdate = NULL,
  enddate = NULL,
  plot = "line",
  sankey_scale = "log",
  include_changeorder = FALSE,
  return_list = FALSE
)

Arguments

resolution

A character of gss resolutions, e.g. OA, LSOA.

gss_codes

A character vector of gss codes to limit the results to. Overrides resolution.

startdate

A date, integer or string that can be read as a vintage. The first date of the period for which you want to extract any changes to the geography. The default, NULL, is interpreted as the earliest date available. A year (e.g. 2011) (string or integer) gives the 31st December of that year, which is the usual way of dating ONS geographic vintages. A month or date, formatted " end of the month if day is excluded). Also accepts Date objects.

enddate

As startdate but for the end of the period you're interested in. Default is NULL, which is the most recent data available.

plot

When NA no plot is drawn. When "line" a timeline is drawn grouping geographies by creation and termination date. When "sankey" a Sankey diagram is drawn. Both diagrams can be overly noisy if the selected resolutions, GSS codes or time periods contain too many elements and can be refined by returning the data via the return_list command, editing, and passing to the package's plot_gss_timeline_line() or plot_gss_timeline_sankey() functions.

sankey_scale

Either "linear" or "log". Whether to scale flows in output Sankey diagrams by their values or the logarithm of their values. (Note that nodes won't be proportional to total flows).

include_changeorder

Logical. If TRUE the output contains two additional columns, changeorder and changeordertitle. These give codes and titles for the legal workings that create and terminate the geographies (and therefore potentially more output rows than when the parameter is set to FALSE since several orders can come into effect on the same date). They're not included by default because the change order names are not unique in the database, and one change order may have several slightly varying titles (see the examples), splitting up changes that ought to be considered as one.

return_list

Logical. By default the function returns the wrangled output from the query as an easy-to-use data frame. For debugging and customisation set this to TRUE and instead return a list with four elements: query containing the SPARQL query sent to the ONS servers. Re-run the query by passing it to query_ons(), or print and inspect it with cat(). The query's response is stored as response. The wrangled output is stored as return - this is what the function returns when return_list is FALSE. The visualisation produced when plot is not NULL is stored as plot. If the plot parameter is "sankey" then sankey_data is returned as a list with a nodes and a links element used in the Sankey diagram.

Details

Used in particular for checking consistency with vintages: check for an empty result.

See also gss_reaggregate(?) for converting gss codes between vintages.

Value

Data frame with XXXXXX, plot XXXXXXX

Examples

1
2
3
4
5
6
7
8
## Not run: 
# Get and plot the change history for all OAs, LSOAs and MSOAs
x <- gss_timeline(c("OA", "LSOA", "MSOA"))

# Get and plot the change history for a single ward
x <- gss_timeline(gss_codes = "E05000021")

## End(Not run)

ChrisFairless/geograpi documentation built on July 4, 2020, 12:01 a.m.