Plots not displaying in Quarto document

Hello. If I run the following code chunks in the R console, everything turns out as expected. However, if I try to render the file, I get no errors but the simple plot does not display.

---
title: "Untitled"
format: html
---

```{r, message=FALSE, warning=FALSE}
#|  label: load-packages
#|  include: false

options(scipen = 100, digits = 4)
library(rmarkdown)
library(quarto)
library(readxl)
library(Hmisc)
library(tidyverse)
library(DT)
library(gtsummary)
library(datasets) # Added for this example
```
# Section 1

Some dummy text for testing purposes.
```{r}
#|  label: viewdata
#| #|:  include: false
summary(iris)
tabs <- function() {
    tbl_summary_1 <- df1 %>%
        tbl_summary(
        by = Species,
            statistic =
            list(all_continuous() ~ "{min} {mean} {median} {sd} {max}",
                all_categorical() ~ "{n} ({p})")
    )
    return(tbl_summary_1)
    tbl_summary_1
}
df1 <- iris # Not needed but inserted for comparability to the function used in source program.
tabs()

plot1 <- ggplot(iris, aes(x = Species, y = Sepal.Length)) +
  geom_boxplot() +
  labs(title = "Box Plot of Sepal Length by Species",
       x = "Species",
       y = "Sepal Length") +
  theme_minimal()

plot1

```

# Section 2
I should have table and plot presented in the Quarto document.

Thank you in advance.

I formatted your code correctly (you need to use more backticks around .qmd source code)

There is still some problems in your cell (like #| #|: include: false).

Anyhow, removing this line I can't reproduce your issue with latest Quarto version.

Can you try again and fix your example ?

The silly error in the line that you noted (#| #|: include: false) was changed to be simply #|: include: false and the plot did not display. Completely removing that line fixed the problem and allowed everything to display.

Thank you. Your answer is marked as the solution.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.