mbannert / tsreports

Define simple time series based rmarkdown reports in yaml
0 stars 0 forks source link

proof of concept #1

Open mbannert opened 6 years ago

mbannert commented 6 years ago

yaml:

----------------------------------------
report_title: some title
report_subtitle: some subtitle
authors: the KOF gang
date: 2018-11-01
layout: two_columns 
global_tsplot_theme: init_tsplot_theme
     sum_as_line: T
     lwd: c(1,2,3)
----------------------------------------

tsplot:
    ch.kof.barometer

tsplot: 
    ch.kof.mpc

tsplot:
     ch.kof.inu.ng08.fx.q_ql_ass_bs.balance
     ch.kof.bau.ng08.fx.q_ql_ass_bs.balance
  1. have a create yaml skeleton funktion -> 1. parse yaml -> 2. create markdown -> 3. run R function
render_tsreport("some.yaml", out_path = NULL,
                              output_format = "pdf", keep_intermediate_files = TRUE)

-> report definition can also be store to db (as json).

HomoCodens commented 6 years ago
report_title: some title
report_subtitle: some subtitle
authors: the KOF gang
date: 2018-11-01
layout: two_columns 
global_tsplot_theme:
  sum_as_line: TRUE
  lwd:
    - 1
    - 2
    - 3
plots:
  - title: Baro
    subtitle: meter
    tsplot_params:
      - left_as_bar: TRUE
    series:
    - ch.kof.barometer
  - title: mpc
    series:
    - ch.kof.mpc
  - title: survey stuff
    series:
    - ch.kof.inu.ng08.fx.q_ql_ass_bs.balance
    - ch.kof.bau.ng08.fx.q_ql_ass_bs.balance
    theme: # Augment of override global_tsplot_theme
      line_colors: 
        - "#000000"
        - "#0f892b"
    window:
      start: 2008
      end: 2018.5

That's already higher level yaml though. Simple arrays (like the lwd and colors above) could also be written in the inline form ([1, 2, 3])

Minimal example:

report_title: stuff
plots:
  - series: [ch.kof.barometer, ch.kof.barometer.ref]
  - series: [ch.kof.inu.ng08.fx.q_ql_ass_bs.balance, ch.kof.bau.ng08.fx.q_ql_ass_bs.balance]

?

Anyway, I think we should aim for out-of-the-box valid yaml.

HomoCodens commented 6 years ago

Also maybe a metadata_field_for_legend-field per plot?

HomoCodens commented 6 years ago

Maybe have an n_periods additionally to / instead of window to allow automatically shifting windows that always include the most recent (or, with another parameter the nth most recent) period.