aplot_lines: Basic PTT line plot

View source: R/plotting.R

aplot_linesR Documentation

Basic PTT line plot

Description

Basic PTT line plot

Usage

aplot_lines(
  dat,
  x = time,
  y = value,
  colour = tiedot,
  size = NULL,
  y2,
  title = "",
  subtitle = "",
  source = NULL,
  caption = "",
  rangeslider = FALSE,
  ...
)

aplot_trends(
  dat,
  x = time,
  y = value,
  colour = tiedot,
  size = NULL,
  title = "",
  subtitle = "",
  source = NULL,
  caption = "",
  rangeslider = FALSE,
  org_showlegend = FALSE,
  trends_only = FALSE,
  ...
)

Arguments

dat

A data.frame to plot.

x

y Variables for x- and y-axis.

colour

A variable for colours

size

A variable for size. Not in use

y2

An optional y-variable for narrow line (forexample original in a trend plot).

title

A plot title

subtitle

A plot subtitle, use also for y-axis label.

source

A source information for caption. Text is added to "Lähde: ..., PTT".

caption

A caption text. Will override source

rangeslider

A locigal for rangeslider

...

Additional arguments for ptt_plot.

org_showlegend

A logical to show legend for original data.

trends_only

A logical to have only trends in plot.

Functions

  • aplot_trends(): Estimate and plot trend with original

Examples

library(pttdatahaku)
library(tidyverse)
ptt_data_robo_l("StatFin/vtp/statfin_vtp_pxt_11sf.px") |>
dplyr::filter(
    taloustoimi %in% c("P7R Tavaroiden ja palvelujen tuonti, tulona",
    "P6K Tavaroiden ja palvelujen vienti, menona"),
    tiedot == c("Volyymin muutokset, %")) |>
    aplot_lines(colour = taloustoimi,
                title = "Vienti ja tuonti",
                subtititle = "%, volyymin muutos",
                source = "Tilastokeskus")

ptt_data_robo("StatFin/ttvi/statfin_ttvi_pxt_13bh.px") |>
filter_recode(toimiala_tol_2008 = c("BCD Koko teollisuus", "19-22 Kemianteollisuus"),
       tiedot = c(indeksi = "Työpäiväkorjattu indeksisarja", trendi = "Trendisarja")) |>
  group_by(toimiala_tol_2008, tiedot) |>
  mutate(value = 100 * (value / lag(value, 12) -1)) |>
  ungroup() |>
  spread(tiedot, value) |>
  filter(time >= "2018-01-01") |>
  aplot_lines(colour = toimiala_tol_2008, y = trendi, y2 = indeksi,
            title = "Teollisuustuotannon volyymi",
            subtitle = "%-muutos, trendi ja työpäiväkorjattu")


ptt_data_robo_l("StatFin/ntp/statfin_ntp_pxt_132h.px") |>
dplyr::filter(
    taloustoimi %in% c("P7R Tavaroiden ja palvelujen tuonti, tulona",
    "P6K Tavaroiden ja palvelujen vienti, menona"),
    tiedot == c("Alkuperäinen sarja, viitevuosi 2015, miljoonaa euroa")) |>
    aplot_trends(colour = taloustoimi,
                title = "Vienti ja tuonti",
                subtititle = "%, volyymin muutos",
                source = "Tilastokeskus")

pttry/pttrobo documentation built on March 5, 2025, 6:36 p.m.