I am trying to create a forest plot using the meta package in R within a Quarto document. However, the plot gets cropped, cutting off some labels and rows at the top and bottom. I tried increasing the body-width in the YAML, which makes the usable space in the HTML wider, but it doesn’t seem to apply to tables or plots like this forest plot. Despite having extra space, the plot doesn’t expand to use it and still gets cut off. Here's my code:
---
title: "Forest Plot"
format: html
---
```{r}
set.seed(123)
proportions <- rnorm(50, mean = 0.4, sd = 0.1)
n <- sample(100:150, 50, replace = TRUE)
study_names <- paste("Study", 1:50)
library(meta)
meta_result <- metaprop(event = proportions * n,
n = n,
studlab = study_names)
forest(meta_result)
```
You can adjust the article layout and figure dimensions to prevent your plot getting cropped.
Example:
#| column: page-right
#| fig-width: 8
#| fig-height: 8
forest(meta_result)