对导入的docx文档进行颜色编码

时间:2019-02-13 00:51:07

标签: r officer

我正在尝试突出显示一组单词,例如使用R中的Officer包从导入的单词文档中突出显示word1word2。现在,在为字。我如何让警务人员在颜色中突出显示单词?

我已经使用read_docx(filename)读取了数据文件。 我还使用fp_text()ftext()设置了文本属性。

my_doc <- read_docx(file.path(filepath,myfile)) 

color1 <- fp_text(color = "blue", font.size = 10, bold = FALSE,
        italic = FALSE, underlined = FALSE, font.family = "Arial",
        vertical.align = "baseline", shading.color = "transparent")
ftext("word1", color1)
color2 <- fp_text(color = "red", font.size = 10, bold = FALSE,
        italic = FALSE, underlined = FALSE, font.family = "Arial",
        vertical.align = "baseline", shading.color = "transparent")
ftext("word2", color1)

1 个答案:

答案 0 :(得分:0)

您必须使用参数shading.color设置突出显示颜色:

color1 <- fp_text(shading.color = "yellow")