在四开本中,我尝试在图形子标题中添加内联代码,我尝试了几种方法,但似乎都不起作用。以下是一个可重现的示例:
test=403.87
#| label: example
#| code-fold: true
#| fig-show: "hold"
#| layout-ncol: 2
#| fig-cap: !expr "paste0('R expression in the caption works: ',test)"
#| fig-subcap:
#| - !expr "test"
#| - !expr "paste0('R expression in the subcaption does not work: ',test)"
library(ggplot2)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "loess", se = FALSE)
ggplot(airquality, aes(Temp, Ozone)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE)