library(officer)
doc <- read_docx()
doc <- docx_set_character_style(
doc,
style_id = "newcharstyle",
style_name = "label for char style",
base_on = "Default Paragraph Font",
fp_text_lite(
shading.color = "red",
color = "white")
)
paragraph <- fpar(
run_wordtext("hello",
style_id = "newcharstyle"))
doc <- body_add_fpar(doc, value = paragraph)
docx_file <- print(doc, target = tempfile(fileext = ".docx"))
docx_file
Run the code above in your browser using DataLab