5

I am creating a quarto html document using R and publishing it to the web at rpubs.com. The document uses only the middle third of the window and leaves the left and right thirds blank. I am showing a table but it is not started on the far left side and as a result it is cut off part way through. How can I tell quarto to use the full window? Here is a reproducible example.

---
title: "Test2"
author: "Philip Smith"
format: html
html: 
  page-layout: custom
editor: visual
code-fold: true
link-external-icon: true
knitr:
  opts_chunk: 
    collapse: true
    comment: "#>" 
    R.options:
      knitr.graphics.auto_pdf: true---
---

    ```{r set-options, echo=FALSE, warning=FALSE, cache=FALSE}
    library(lubridate)
    library(gt)
    FdfT <- structure(list(Name = c("LFS participation rate", "LFS employment rate", 
    "LFS unemployment rate", "Job vacancy rate", "LFS payroll", "LFS payroll employment", 
    "LFS payroll average hours worked", "LFS payroll average hourly earnings", 
    "SEPH payroll", "SEPH payroll employment", "SEPH payroll average hours worked", 
    "SEPH payroll average hourly earnings", "LFS payroll", "LFS payroll employment", 
    "LFS payroll average hours worked", "LFS payroll average hourly earnings", 
    "SEPH payroll", "SEPH payroll employment", "SEPH payroll average hours worked", 
    "SEPH payroll average hourly earnings"), V1 = c(65.4, 61.5, 6, 
    5.6, 8.9, 5.8, 0.3, 2.7, 9.2, 6.8, -0.3, 2.3, 0.8, 0.3, 0.1, 
    0.4, 1.3, 0.6, 0.6, 0.1), V2 = c(65, 60.8, 6.5, 5.4, 7.7, 5.8, 
    -0.6, 2.3, 9.3, 7.8, -0.6, 2, -0.2, -1.5, 0.4, 0.9, 0.9, 0.1, 
    0, 0.9), V3 = c(65.4, 61.8, 5.5, 5.3, 9.5, 6.3, 0, 3.1, 10.1, 
    8, -0.6, 2.5, 1.9, 2.3, -0.3, -0.1, 0.8, 0.7, 0, 0), V4 = c(65.4, 
    61.9, 5.3, 5.7, 9.1, 5.1, 0.3, 3.5, 11.8, 7.2, -0.6, 4.9, 0.7, 
    0.3, 0.1, 0.3, 2.2, 0.8, -0.3, 1.7), V5 = c(65.3, 61.9, 5.2, 
    5.7, 9.3, 6.3, -0.5, 3.3, 10.2, 7, -1.2, 4.3, -0.2, 0, -0.6, 
    0.4, 0.2, 0.7, 0, -0.4), V6 = c(65.3, 61.9, 5.1, 5.7, 10.9, 7.2, 
    -0.6, 3.9, 11.5, 8.6, -0.9, 3.5, 1.2, 0.2, 0.2, 0.8, -0.4, 0, 
    -0.3, -0.3), V7 = c(64.9, 61.7, 4.9, 5.6, 11.3, 5.2, 0.6, 5.2, 
    11.2, 7.8, -0.6, 3.9, 1.3, 0.1, 0.5, 0.7, 1, 0.8, 0, 0.4), V8 = c(64.7, 
    61.6, 4.9, 5.5, 10.5, 4.2, 0.9, 5.2, 9, 5.9, -0.6, 3.3, 0, -0.4, 
    -0.1, 0.4, 0.1, 0.1, 0, -0.1), V9 = c(64.8, 61.3, 5.4, 5.3, 9.4, 
    3.5, 0.3, 5.4, 9.2, 5.5, 0, 3.6, 0.2, -0.1, -0.4, 0.6, 0.8, 0, 
    0, 0.9), V10 = c(64.7, 61.3, 5.2, 5.2, 8.5, 2.6, 0.6, 5.2, 9.1, 
    5.5, -0.6, 3.8, 0.5, 0.2, 0.3, 0, 0.8, 0.5, -0.3, 0.4), V11 = c(64.9, 
    61.6, 5.2, 4.9, 8.8, 2.8, 0.3, 5.5, 7.9, 4.7, -1.2, 4.1, 1.1, 
    0.5, -0.1, 0.7, -0.6, 0, -0.6, 0.1), V12 = c(64.8, 61.5, 5.1, 
    NA, 8.3, 2, 0.5, 5.6, NA, NA, NA, NA, 0.7, 0, 0.3, 0.5, NA, NA, 
    NA, NA), V13 = c(65, 61.8, 5, NA, 7.7, 2.1, 0.3, 5.2, NA, NA, 
    NA, NA, 0.2, 0.4, -0.1, 0, NA, NA, NA, NA)), row.names = c(NA, 
    -20L), class = "data.frame")
    
    LASTdate <-"2022-12-01" 
    NumMths <- 12
    Dates <- seq.Date(as.Date("2021-12-01"),as.Date("2022-12-01"),by="month")
    colls <- c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11","V12","V13")
    MyTitle <- paste0("**Labour market indicators<br>",format(Dates[1],"%B %Y"),
      " to ",format(Dates[13],"%B %Y"),"**")
    gt_tbl1 <- gt(data=FdfT)
    gt_tbl1 <- gt_tbl1 %>% 
      tab_options(table.font.size=12,container.width = 1450) %>%
      tab_header(
        title=md(html(MyTitle))
      ) %>% 
      cols_align(
        align=c("left"),
        columns=c(`Name`)
      ) %>%
      fmt_number(
        columns=all_of(colls),
        decimals=1,
        use_seps=TRUE
      ) %>%
      cols_label(
        `Name`="",
        `V1`=md("**Dec<br>2021**"),
        `V2`=md("**Jan<br>2022**"),
        `V3`=md("**Feb<br>2022**"),
        `V4`=md("**Mar<br>2022**"),
        `V5`=md("**Apr<br>2022**"),
        `V6`=md("**May<br>2022**"),
        `V7`=md("**Jun<br>2022**"),
        `V8`=md("**Jul<br>2022**"),
        `V9`=md("**Aug<br>2022**"),
       `V10`=md("**Sep<br>2022**"),
       `V11`=md("**Oct<br>2022**"),
       `V12`=md("**Nov<br>2022**"),
       `V13`=md("**Dec<br>2022**")
      ) %>%
      sub_missing(columns=everything(),rows=everything(),
        missing_text="---") %>%
      tab_style(
        style = list(
          cell_text(weight = "bold")
          ),
        locations = cells_title()
      ) %>%
      tab_style( # column label style
        style = list(
          cell_text(weight = "bold")
        ),
        locations = cells_column_labels(
          columns=c(Name,all_of(colls)))
      ) %>%
      tab_row_group(label="Ratio, per cent",
        rows=c(1:4),id="Levels") %>%
      tab_row_group(label="12-month percentage change, per cent",
        rows=c(5:12),id="PC12") %>%
      tab_row_group(label="1-month percentage change, per cent",
        rows=c(13:20),id="PC01") %>%
      opt_row_striping(row_striping = TRUE) %>%
      opt_vertical_padding(scale = 0.25) %>%
      tab_footnote(
          footnote = paste0("Dashes mean 'data not yet available'. Source for ",
          "data: Statistics Canada. @PhilSmith26.    Prepared: ",Sys.time()),
          locations = cells_title()
    )
    gt_tbl1
    ```
Phil Smith
  • 430
  • 2
  • 12

1 Answers1

4

I discovered that one must update to the pre-release 1.3 of quarto. Then the following YAML code does the job.

format:
  html: 
    grid:
      sidebar-width: 0px
      body-width: 2000px
      margin-width: 0px
      gutter-width: 1.5rem
shafee
  • 15,566
  • 3
  • 19
  • 47
Phil Smith
  • 430
  • 2
  • 12