My client has given me text data with HTML tags <b>
and </b>
. I am producing a pdf report with RMarkdown. I converted the HTML to markdown like this:
mutate(plot_group=as.factor(plot_group),
## this part inserted to replace HTML with markdown
text.tmp = str_replace(`Item Text`, "<b>", "**"),
text.final = str_replace(text.tmp, "</b>", "**"))
Then I print the result with geom_richtext()
:
ggplot(items.to.plot, aes(x=plot_group, y=measure, label=wrap_strings(text.final, 16), color=as.factor(extra))) +
geom_point() +
geom_richtext(fill = NA, label.color = NA, hjust=-.3, size=6) +
geom_text_repel(size=2)
But when I do that I get this error message:
Error in `geom_richtext()`:
! Problem while converting geom to grob.
i Error occurred in the 2nd layer.
Caused by error:
! gridtext has encountered a tag that isn't supported yet: <ol>
Only a very limited number of tags are currently supported.
I guess the problem occurs somewhere internal to geom_text_repel()
or something, but nothing that's easy for me to fix.
I found another post on stackoverflow that does the job using phantom()
but it seems phantom()
been removed from CRAN.
Can anyone suggest another solution?