Currently if I want to show data in a table in R I can hyperlink text via markdown, html href, or LaTeX href. This is often nice for giving access to more info about a particular element w/o cluttering the table.
How is it possible to give the same kinds of hyperlinked text in a visualization made with ggplot2?
So for example if I make this plot:
With the code below, how can I make the axis text hyperlink to the wikipedia pages that correspond?
library(tidyverse)
mtcars %>%
rownames_to_column('car') %>%
slice(5:8) %>%
mutate(
link = c(
'https://de.wikipedia.org/wiki/AMC_Hornet',
'https://en.wikipedia.org/wiki/Plymouth_Valiant',
'https://en.wikipedia.org/wiki/Plymouth_Duster',
'https://en.wikipedia.org/wiki/Mercedes-Benz_W123'
)
) %>%
ggplot(aes(x = mpg, y = car)) +
geom_point(size = 2)
ggplotly
for the initial conversion. I don't think any option will be simple, though.gridSVG
package shows ways to add links to grobs when viewed in the browser. So you can use separate grobs for points, labels etc and add links to these (Ive had a wee go with this here)