如何在ReporteRs::addPlot中设置字体类型和名称?
How to set font type and name in ReporteRs::addPlot?
下面的代码创建了一个图表,并使用出色的 ReporteRs 包将其嵌入到 Word 文档中。代码生成警告:
"argument fontname is deprecated; please usefontname_serif, fontname_sans,fontname_mono,fontname_symbol instead"
我一直无法弄清楚如何指定特定的字体,例如"Times New Roman"。谢谢!
library(ReporteRs)
library(magrittr)
x <- rnorm(100); y <- (1.5 * x) + rnorm(100, 0.1)
options( "ReporteRs-fontsize" = 12 )
doc <- docx() %>%
addPlot(function() plot(x,y, xlab = "Values of x", main="Test plot"), vector.graphic=TRUE, editable=TRUE, fontname="Times New Roman")
writeDoc( doc, file = "test.docx")
reporters-package google群包作者提供的解决方案:
https://groups.google.com/forum/#!topic/reporters-package/x3a_qWQ0hGc
doc <- docx() %>%
addPlot(function() plot(x,y, xlab = "Values of x", main="Test plot", family="serif"), vector.graphic=TRUE,
editable=TRUE, fontname_serif = "Times New Roman")
writeDoc( doc, file = "test.docx")
下面的代码创建了一个图表,并使用出色的 ReporteRs 包将其嵌入到 Word 文档中。代码生成警告:
"argument fontname is deprecated; please usefontname_serif, fontname_sans,fontname_mono,fontname_symbol instead"
我一直无法弄清楚如何指定特定的字体,例如"Times New Roman"。谢谢!
library(ReporteRs)
library(magrittr)
x <- rnorm(100); y <- (1.5 * x) + rnorm(100, 0.1)
options( "ReporteRs-fontsize" = 12 )
doc <- docx() %>%
addPlot(function() plot(x,y, xlab = "Values of x", main="Test plot"), vector.graphic=TRUE, editable=TRUE, fontname="Times New Roman")
writeDoc( doc, file = "test.docx")
reporters-package google群包作者提供的解决方案:
https://groups.google.com/forum/#!topic/reporters-package/x3a_qWQ0hGc
doc <- docx() %>%
addPlot(function() plot(x,y, xlab = "Values of x", main="Test plot", family="serif"), vector.graphic=TRUE,
editable=TRUE, fontname_serif = "Times New Roman")
writeDoc( doc, file = "test.docx")