admin管理员组

文章数量:1390410

I'm working on a Quarto project in VS code with a .qmd file ("01_data_exploration.qmd") that includes a ggplot2 plot. The plot displays correctly in an interactive R session, but when I render the .qmd to HTML, I get a 404 error referencing a missing figure file:

Watching files for changes
Browse at http://localhost:5335/
Rendering HTML preview [index.qmd]
GET: /
GET: /notebooks/01_data_exploration-preview.html
/notebooks/01_data_exploration_files/figure-html/germ-1.png (404: Not Found)

My R codeblock within my .qmd file looks like this:

# Create plot
p <- ggplot(mean_per_regiontype_DE, aes(x = month, y = mean_active_per_100k, color = lage_typ)) +
  geom_line() +
  geom_point() +
  scale_x_date(date_breaks = "1 month", date_labels = "%b %Y") +
  labs(title = "Germany: Mean active per 100k pro Regionstyp",
       x = "Month",
       y = "Mean active per 100k",
       color = "Region type") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 90, hjust = 1))

# Explicitly print the plot
print(p)

The figure actually seems to be saved in a different folder than Quarto expects. How can I make sure Quarto places the figure in the correct location so it shows up in my final HTML document?

Any help or suggestions are much appreciated!

knitr::opts_chunk$set(echo = TRUE)

didnt help:(

本文标签: knitrWhy does my Quarto document produce a 404 error for R plots when I renderStack Overflow