compare_areas: Plot compare areas chart

Description Usage Arguments Value See Also Examples

View source: R/quick_charts.R

Description

Returns ggplot of compare areas chart

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
compare_areas(
  data,
  area,
  value,
  lowerci,
  upperci,
  fill,
  order = "desc",
  top_areas,
  title = "",
  xlab = "",
  ylab = "",
  legend.position = "bottom",
  display.values = FALSE,
  dps = 1
)

Arguments

data

data.frame object to plot using ggplot2 functions

area

field containing variable to be plotted on y axis (unquoted)

value

field containing variable to be plotted on x axis (unquoted)

lowerci

field containing variable to be plotted as lower confidence interval (unquoted - not required)

upperci

string; field containing variable to be plotted as upper confidence interval (unquoted - not required)

fill

field to be used to determine the colouring of the bars (unquoted)

order

one of "alphabetical", "asc" or "desc" - to determine how to order the bars

top_areas

character vector; the areas to fix at the top of the chart

title

string; title of chart

xlab

string; x-axis title

ylab

string; y-axis title

legend.position

the position of legends ("none", "left", "right", "bottom", "top", or two-element numeric vector)

display.values

logical; where or not to display the rounded values next to the bars on the chart

dps

number; number of decimal places to be displayed when display.values = TRUE. The default is 1.

Value

a ggplot of a compare areas chart

See Also

Other quick charts: box_plots(), compare_indicators(), map(), overview(), population(), trends()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(dplyr)
df <- create_test_data()
parent <- "PAC11"
top_names <- c("C001", parent)
ordered_levels <- c("Better",
                    "Similar",
                    "Worse",
                    "Not compared")
df_ca <- df %>%
        filter(IndicatorName == "Indicator 3",
               (AreaCode %in% top_names |
                        ParentAreaCode == parent))
p <- compare_areas(df_ca, AreaCode, Value,
                   fill = Significance,
                   lowerci = LCI,
                   upperci = UCI,
                   order = "desc",
                   top_areas = top_names,
                   title = "Compare the local areas")
p

fingertipscharts documentation built on July 2, 2020, 2:59 a.m.