请考虑以下内容:
对于使用bookdown
(HTML和PDF)编写的报告,我想引用在ggplot2
图形中使用的形状。在rmarkdown
中,可以通过调用object
内联引用`r object`
或R代码。
问题:我们如何“打印” ggplot2
shape
内联?
示例
下图描述了cyl
数据集中变量mtcars
的标准箱线图。描述数据均值不是标准,但很高兴。此处,平均值使用shape
数字23添加到箱线图中。
library(ggplot2)
ggplot(data = mtcars,aes(x = cyl,y = disp,group = cyl)) +
geom_boxplot() +
stat_summary(fun.y = mean,geom = "point",shape = 23,size = 3) +
facet_wrap(~ cyl,scales = "free")
由reprex package(v0.3.0)于2019-11-20创建
在我的文字中,我想通过编写类似以下内容的内容来显式引用此shape
内联:
“ `r print(shape == 23)`
是指圆柱[...]的平均值。