Finally fix alignment issues (and more improvements to tables)

This commit is contained in:
2025-05-20 23:12:04 +02:00
parent 8a0cf4564b
commit f4cfddfd4e
2 changed files with 58 additions and 50 deletions

View File

@@ -1,11 +1,30 @@
/*-- scss:defaults --*/ /*-- scss:defaults --*/
$body-bg: #ffffff; // $body-bg: #ffffff;
$body-color: #7a6f69; // $body-color: #7a6f69;
$link-color: #005088; // $link-color: #005088;
$selection-color: #00b0dc; // $selection-color: #00b0dc;
$presentation-heading-color: $selection-color; // $presentation-heading-color: $selection-color;
$tabset-border-color: #bbb3b0; // $tabset-border-color: #bbb3b0;
/*-- scss:rules --*/ /*-- scss:rules --*/
.slide-number,
.reveal.has-logo .slide-number {
bottom: 14px !important;
left: 50px !important;
top: unset !important;
color: #777777 !important;
}
.sup-zero-width {
display: inline-block;
vertical-align: super;
font-size: smaller;
width: 0px;
}
.zero-width {
display: inline-block;
width: 0px;
}

View File

@@ -1,21 +1,22 @@
--- ---
title: "Data Science Methods for Forecasting in Energy and Economics" title: "Data Science Methods for Forecasting in Energy and Economics"
date: 2025-07-10 date: 30 June 2025
author: author:
- name: Jonathan Berrisch - name: Jonathan Berrisch
affiliations: affiliations:
- ref: hemf - ref: hemf
affiliations: affiliations:
- id: hemf - id: hemf
name: University of Duisburg-Essen, House of Energy Markets and Finance name: University of Duisburg-Essen, House of Energy, Climate and Finance
format: format:
revealjs: revealjs:
embed-resources: true embed-resources: true
footer: "" footer: ""
logo: assets/logos_combined.png logo: assets/logos_combined.png
theme: [default, clean.scss] theme: [default, sydney.scss, custom.scss]
smaller: true smaller: true
fig-format: svg fig-format: svg
slide-number: true
execute: execute:
daemon: false daemon: false
highlight-style: github highlight-style: github
@@ -109,8 +110,6 @@ xaringanExtra::use_freezeframe(responsive = TRUE)
# Motivation # Motivation
name: motivation
## Motivation ## Motivation
:::: {.columns} :::: {.columns}
@@ -1234,14 +1233,14 @@ for (i.p in 1:MO) {
table_col[, i.p] <- rgb(fred, fgreen, fblue, maxColorValue = 1) table_col[, i.p] <- rgb(fred, fgreen, fblue, maxColorValue = 1)
} # i.p } # i.p
table_out <- kbl(table, align = rep("c", ncol(table))) table_out <- kbl(table, align = rep("c", ncol(table)), bootstrap_options = c("condensed")) %>%
kable_paper(full_width = TRUE)
for (j in 1:ncol(table)) { for (j in 1:ncol(table)) {
table_out <- table_out %>% table_out <- table_out %>%
column_spec(j, background = table_col[, j]) column_spec(j, background = table_col[, j])
} }
table_out %>% table_out
kable_material()
``` ```
```{r, echo = FALSE, fig.width=7, fig.height=5.5, fig.align='center', cache = FALSE, results='asis'} ```{r, echo = FALSE, fig.width=7, fig.height=5.5, fig.align='center', cache = FALSE, results='asis'}
@@ -1272,7 +1271,8 @@ for (i.p in 1:MO) {
table_col2[, i.p] <- rgb(fred, fgreen, fblue, maxColorValue = 1) table_col2[, i.p] <- rgb(fred, fgreen, fblue, maxColorValue = 1)
} # i.p } # i.p
table_out2 <- kableExtra::kbl(table2, align = rep("c", ncol(table2))) table_out2 <- kableExtra::kbl(table2, align = rep("c", ncol(table2)), bootstrap_options = c("condensed")) %>%
kable_paper(full_width = TRUE)
for (j in 1:ncol(table2)) { for (j in 1:ncol(table2)) {
table_out2 <- table_out2 %>% table_out2 <- table_out2 %>%
@@ -1282,7 +1282,6 @@ for (j in 1:ncol(table2)) {
} }
table_out2 %>% table_out2 %>%
kable_material() %>%
column_spec(1, bold = T) column_spec(1, bold = T)
``` ```
@@ -1781,7 +1780,7 @@ Computation Time: ~30 Minutes
:::: ::::
# Special Cases ## Special Cases
:::: {.columns} :::: {.columns}
@@ -1842,7 +1841,7 @@ knitr::include_graphics("assets/mcrps_learning/smooth_best.svg")
:::: {.columns} :::: {.columns}
::: {.column width="65%"} ::: {.column width="55%"}
```{r} ```{r}
load("assets/mcrps_learning/naive_table_df.rds") load("assets/mcrps_learning/naive_table_df.rds")
@@ -1856,10 +1855,11 @@ table_naive <- naive_table_df %>%
bootstrap_options = "condensed", bootstrap_options = "condensed",
escape = FALSE, escape = FALSE,
format = "html", format = "html",
booktabs = TRUE, booktabs = FALSE,
align = c("c", rep("c", ncol(naive_table_df) - 1)) align = c("c", rep("c", ncol(naive_table_df) - 1))
) %>% ) %>%
kable_paper(full_width = TRUE) %>% kable_paper(full_width = TRUE) %>%
row_spec(0:1, color = cols[10, "grey"]) %>%
kable_styling(font_size = 16) kable_styling(font_size = 16)
@@ -1887,29 +1887,27 @@ for (j in 1:3) {
for (i in seq_len(nrow(performance_loss_tibble))) { for (i in seq_len(nrow(performance_loss_tibble))) {
if (loss_and_dm[i, j, "p.val"] < 0.001) { if (loss_and_dm[i, j, "p.val"] < 0.001) {
performance_loss_tibble[i, 2 + j] <- paste0( performance_loss_tibble[i, 2 + j] <- paste0(
"&nbsp;&nbsp;",
performance_loss_tibble[i, 2 + j], performance_loss_tibble[i, 2 + j],
"\\(^{***}\\)" '<span class="sup-zero-width">***</span>'
) )
} else if (loss_and_dm[i, j, "p.val"] < 0.01) { } else if (loss_and_dm[i, j, "p.val"] < 0.01) {
performance_loss_tibble[i, 2 + j] <- paste0( performance_loss_tibble[i, 2 + j] <- paste0(
"&nbsp;&nbsp;", performance_loss_tibble[i, 2 + j],
performance_loss_tibble[i, 2 + j], "\\(^{**}\\)" '<span class="sup-zero-width">**</span>'
) )
} else if (loss_and_dm[i, j, "p.val"] < 0.05) { } else if (loss_and_dm[i, j, "p.val"] < 0.05) {
performance_loss_tibble[i, 2 + j] <- paste0( performance_loss_tibble[i, 2 + j] <- paste0(
"&nbsp;&nbsp;", performance_loss_tibble[i, 2 + j],
performance_loss_tibble[i, 2 + j], "\\(^{*}\\)" '<span class="sup-zero-width">*</span>'
) )
} else if (loss_and_dm[i, j, "p.val"] < 0.1) { } else if (loss_and_dm[i, j, "p.val"] < 0.1) {
performance_loss_tibble[i, 2 + j] <- paste0( performance_loss_tibble[i, 2 + j] <- paste0(
"&nbsp;&nbsp;", performance_loss_tibble[i, 2 + j],
performance_loss_tibble[i, 2 + j], "\\({.}\\)" '<span class="zero-width">.</span>'
) )
} else { } else {
performance_loss_tibble[i, 2 + j] <- paste0( performance_loss_tibble[i, 2 + j] <- paste0(
"&nbsp;&nbsp;", performance_loss_tibble[i, 2 + j]
performance_loss_tibble[i, 2 + j], "&emsp;"
) )
} }
} }
@@ -1921,18 +1919,18 @@ table_performance <- performance_loss_tibble %>%
col.names = c( col.names = c(
'Description', 'Description',
'Parameter Tuning', 'Parameter Tuning',
'&emsp;&emsp;BOA', 'BOA',
'&emsp;&nbsp;ML-Poly', 'ML-Poly',
'&emsp;&emsp;EWA' 'EWA'
), ),
bootstrap_options = "condensed", bootstrap_options = "condensed",
# Dont replace any string, dataframe has to be valid latex code ... # Dont replace any string, dataframe has to be valid latex code ...
escape = FALSE, escape = FALSE,
format = "html", format = "html",
align = c(rep("l", ncol(performance_loss_tibble))) align = c("l", "l", rep("c", ncol(performance_loss_tibble)-2))
) %>% ) %>%
kable_paper(full_width = TRUE) %>% kable_paper(full_width = TRUE) %>%
row_spec(1:nrow(performance_loss_tibble), monospace = TRUE) row_spec(0:nrow(performance_loss_tibble), color = cols[10, "grey"])
# %% # %%
@@ -1953,21 +1951,11 @@ for (i in 3:ncol(performance_loss_tibble)) {
) )
} }
table_performance %>% table_performance %>%
# footnote(
# general = c(
# "Coloring w.r.t. test statistic: ",
# col_note_html,
# signif
# ),
# general_title = "",
# fixed_small_size = TRUE,
# escape = FALSE
# ) %>%
kable_styling(font_size = 16) kable_styling(font_size = 16)
``` ```
```{=html} ```{=html}
<div style="font-size: 0.7em; margin-top: 0.5em;"> <div style="font-size: 0.6em; margin-top: 0.5em;">
<span style="padding: 2px 6px;">Coloring w.r.t. test statistic: </span> <span style="padding: 2px 6px;">Coloring w.r.t. test statistic: </span>
<span style="background-color: #66BA6A; padding: 2px 6px;">&lt;-5</span> <span style="background-color: #66BA6A; padding: 2px 6px;">&lt;-5</span>
<span style="background-color: #7CC168; padding: 2px 6px;">-4</span> <span style="background-color: #7CC168; padding: 2px 6px;">-4</span>
@@ -1989,7 +1977,7 @@ table_performance %>%
::: :::
::: {.column width = "35%"} ::: {.column width = "45%"}
Foo Foo
@@ -2608,7 +2596,8 @@ table_energy <- energy %>%
format = "html", format = "html",
align = c("l", rep("r", ncol(energy) - 1)) align = c("l", rep("r", ncol(energy) - 1))
) %>% ) %>%
kable_paper(full_width = FALSE) kable_paper(full_width = FALSE) %>%
row_spec(0:nrow(energy), color = cols[10, "grey"])
for (i in 2:ncol(energy)) { for (i in 2:ncol(energy)) {
bold_cells <- rep(FALSE, times = nrow(energy)) bold_cells <- rep(FALSE, times = nrow(energy))
@@ -2634,8 +2623,8 @@ for (i in 2:ncol(energy)) {
table_energy %>% table_energy %>%
kable_styling( kable_styling(
bootstrap_options = c("condensed"), bootstrap_options = c("condensed"),
full_width = FALSE, full_width = TRUE,
font_size = 16 font_size = 14
) )
``` ```