trends: Plot trend chart

Description Usage Arguments Value See Also Examples

View source: R/quick_charts.R

Description

Plot trend chart

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
trends(
  data,
  timeperiod,
  value,
  area,
  comparator,
  area_name,
  fill,
  lowerci,
  upperci,
  title = "",
  subtitle = "",
  xlab = "",
  ylab = "",
  point_size = 4
)

Arguments

data

data.frame object to plot using ggplot2 functions

timeperiod

field containing the time period (unquoted)

value

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

area

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

comparator

string; name of comparator area (this should exist in the field described by the area parameter)

area_name

string; name of the local area (this should exist in the field described by the area parameter)

fill

field to be used to determine the colouring of the bars (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)

title

string; title of chart

subtitle

string; text to use as subtitle to graph

xlab

string; x-axis title

ylab

string; y-axis title

point_size

number; size of point

Value

a ggplot of trends for an indicator alongside a comparator

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(dplyr)
df <- create_test_data()

df_trend <- df %>%
        arrange(IndicatorName) %>%
        mutate(Timeperiod = rep(c("2011", "2012", "2013", "2014", "2015", "2016"),
                                each = 111))
p <- trends(df_trend,
            timeperiod = Timeperiod,
            value = Value,
            area = AreaCode,
            comparator = "C001",
            area_name = "AC142",
            fill = Significance,
            lowerci = LCI,
            upperci = UCI,
            title = "Trend compared to country",
            subtitle = "For area AC142",
            xlab = "Year",
            ylab = "Value (%)")
p

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