Is it possible to create a gt table in an rmarkdown document which includes weblinks which can be clicked? I have seen the html() helpers (https://gt.rstudio.com/reference/html.html), but fail to understand how this can be used for the content of a cell.
Many thx!
library(tidyverse)
library(gt)
df <- data.frame(
stringsAsFactors = FALSE,
country = c("UK", "US"),
name = c("BBC", "CNN"),
link = c("https://www.bbc.com/news", "https://edition.cnn.com/")
df %>%
gt()
One possibility to do this is shown in the code below:
when formatting the link column convert the url to a hyperlink to that url with the same reference text.
We can do that by using the fmt function to format the link column with the make_hyperlink function.
This is an equivalent solution. On my side, I modified the table before applying gt() but you modify only at the formatting stage when building the table. Clever! I find the your formatting function simpler and clever !
Thanks for sharing !