Using the function gt in R, I can get hyperlinks working for cells in the table, but I can't quite figure out how to do it for column names.
library(gt)
library(tidyverse)
make_into_links <- function(vec){
clean_vec <- str_replace_all(vec[-1], ":", "")%>%
str_replace_all(" ", "+")
link <- paste0("https://www.google.com/search?q=", clean_vec, "&btnI")
column_names <- paste0("<a href=", link, ">", vec[-1], "</a>")
column_names <- as.character(c(vec[1], column_names))
}
df <- tibble(
id_col = 1:2,
`usa: some other text` = rnorm(2),
`uk: some other text` = rnorm(2)
)
colnames(df) <- make_into_links(colnames(df))
gt(df)
Created on 2023-06-26 with reprex v2.0.2