I'm using the officer package to automate powerpoint reporting but I am encountering the below error:
"Error in xml_ns.xml_document(x) : external pointer is not valid"
when I try to run the code below. Essentially I am trying to bold the word "specifically:" in line 4 of the code below. But when I run it I get that error message. I searched online and it seems to happen within other use cases such as this: Using rvest with drake: external pointer is not valid error
but I don't really understand how to incorporate their code chunk. Can anyone help?
#these 3 lines below create formatting such as bold, font size etc.
p_normal <- fp_text(font.size = 24)
fp_bold <- update(fp_normal, bold = TRUE) #created the bold option
fp_red <- update(fp_normal, color = "red")
#this line creates an object with the bold option incorporated
studyobjective1 <- block_list(fpar(ftext("Specifically:", fp_bold)),
fpar(ftext("red text", fp_red)))
#and this creates the powerpoint slides. I redacted some names but that shouldnt affect your understanding
#as they are text names not functions etc
#begin by adding slides now that we have named all slides in template and placeholders
trial <- df %>%
add_slide(layout = "study objective", master = "rlayout") %>% #new slide
ph_with("Study Objective", location = ph_location_label(ph_label = "title")) %>%
ph_with("Survey Global Sales - Specifically:",
location = ph_location_label(ph_label = "center object")) %>%
ph_with(studyobjective1, location = ph_location_label(ph_label = "lower object")) %>%
print(target = "C:/Users/mi/Desktop/R/PPT/df.pptx") #save in new location
But when I print the powerpoint slide the word "specifically" isn't bolded which should be due to sudyobjective1 object containing the bold formatting. Instead I get the error in the title of this post. Any ideas?