I would like to create a pdf with rmarkdown. The PDF should contain a table. The table should have a dynamic column label.
The tabhead should display the calendar week.
However, the calendar week (e.g., KW29) is not displayed but the variable name "kw0".
What is my error?
library(knitr)
library(kableExtra)
library(lubridate)
options(knitr.table.format = "latex")
loadData <- function() {# load some data}
myData<- loadData ()
kw0 <- paste("KW", week(Sys.Date()) - 1, sep = "")
kw1 <- paste("KW", week(Sys.Date()), sep = "")
kw2 <- paste("KW", week(Sys.Date()) + 1, sep = "")
kw3 <- paste("KW", week(Sys.Date()) + 2, sep = "")
kable(myData, row.names = FALSE, booktabs = T) %>%
kable_styling(
full_width = TRUE,
font_size = 14
) %>% add_header_above(header = c(" " = 1, kw0 = 2, kw1 = 2, kw2 = 2, kw3 = 2))
I am glad about your advice.