knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
# library(pttrobo)
library(tidyverse)
library(statfitools)
library(lubridate)
library(pttdatahaku)
devtools::load_all()

release_time <- "2022-10-06 10:00:00 EEST"
# release_time <- FALSE
start_time <- "2014-01-01"

read_ennuste_data <- function(ennuste_data_file) {
  readxl::read_excel(ennuste_data_file)
}
ennuste_data <-
  read_ennuste_data(
    here::here("inst", "ennustekuvat", "ptt_ennusteet_KT_2022_1.xlsx")
  )

file_path <- path.expand(file.path("~/test"))

BKT Suomi

ptt_data_robo("StatFin/ntp/statfin_ntp_pxt_132h.px") |>
  filter(
    taloustoimi == "B1GMH Bruttokansantuote markkinahintaan",
    tiedot == "Kausitasoitetun ja työpäiväkorjatun sarjan volyymin muutos vuodentakaisesta, %",
    time >= "2014-01-01"
  ) |>
  mutate(tiedot = "BKT") |>
  ptt_plot(
    grouping = tiedot,
    title = "BKT Suomi",
    subtitle = "%, vuosimuutos",
    caption =  "Lähde: Tilastokeskus ja PTT",
    rangeslider = FALSE,
    zeroline = T,
    font_size = 14,
    height = 500,
    hovertext =  list(rounding = 1, unit = "%", extra = "")
  ) |>
  ptt_plot_add_prediction(ennuste_data) |>
  ptt_plot_create_widget(filepath = file_path)
# print(tempdir())

ptt_plot_upload_widgets(overwrite = T, release_time = release_time, files_path = file_path)

# basename(rstudioapi::documentPath())


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