swiss_history: Real Time Data For Switzerland

Description Format Source Examples

Description

Real Time Data For Switzerland

Format

data frame

Source

SECO

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## Not run: 
## import latest data
url <- paste0(
  "https://www.seco.admin.ch/dam/seco/de/dokumente/Wirtschaft/",
  "Wirtschaftslage/VIP%20Quartalssch%C3%A4tzungen/",
  "realtime_database.xls.download.xls/realtime_database.xls"
)

library(readxl)
library(dplyr)
library(tidyr)
library(tsbox)
library(timemachine)

tf <- tempfile(fileext = ".xls")
download.file(url, tf)


sheets <- readxl::excel_sheets(tf)

swiss_history <-
  tibble(id = setdiff(sheets, "title")) %>%
  rowwise() %>%
  mutate(data = list(read_excel(path = tf, sheet = id, skip = 10))) %>%
  ungroup() %>%
  unnest(cols = c(data)) %>%
  rename(ref_date = X__1) %>%
  gather(pub_date, value, -id, -ref_date) %>%
  mutate_at(c("ref_date", "pub_date"), parse_date_2000colon1) %>%
  select(id, pub_date, ref_date, value) %>%
  filter(!is.na(value))

# save(swiss_history, file = "data/swiss_history.RData", compress='xz')

## End(Not run)
data(swiss_history)
swiss_history

christophsax/timemachine documentation built on Feb. 1, 2021, 2:05 p.m.