I'm using flextable
and officer
to write tables to powerpoints that have hyperlinked cells. When a URL has an &
in it, though, the &
gets replaced with &
. It still works in the flextable in the viewer of my RStudio window, but changes when I export to powerpoint. Here's an example (with a fake link to illustrate what's happening):
library(officer)
library(flextable)
library(magrittr)
link <- "google.com/fake?action=click&module=Top"
# Make the table
ft <- data.frame(x = "Hello", link = link) %>%
flextable() %>%
compose(j = 1, value = as_paragraph(hyperlink_text(x = x, url = link)))
# Add to a slide
my_pres <- read_pptx() %>%
add_slide() %>%
ph_with(value = ft, location = ph_location_type(type = "body"))
print(my_pres, "~/Desktop/example.pptx")
When I open up the powerpoint, the link has been replaced with: google.com/fake?action=click&module=Top.
I removed and reinstalled officer
and flextable
, and now the same code produces this link: google.com/fake%3Faction%3Dclick%26module%3DTop. I'm on officer 0.3.17
and flextable 0.6.4
.
Is there something going on with the XML that I have to escape to keep the URL the same?