-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
For now, there is only one link per variable. But if in the future, there is more than one, this code could be helpful:
library(reactable)
df <- data.frame(
ID = "Link to the right of this text",
url1_text = "Pharmaverse Repo",
url1 = "https://github.com/pharmaverse/falcon",
url2_text = "ddsjoberg forked Repo",
url2 = "https://github.com/ddsjoberg/falcon"
)
rtbl <-
df |>
dplyr::select(ID, url1) |>
reactable(
columns = list(
url1 = colDef(
name = "URL",
cell = function(value, index) {
label1 <- df[index, "url1_text"]
label2 <- df[index, "url2_text"]
url1 <- df[index, "url1"]
url2 <- df[index, "url2"]
htmltools::div(
htmltools::p(
htmltools::tags$a(href = url1, target = "_blank", label1)
),
htmltools::p(
htmltools::tags$a(href = url2, target = "_blank", label2)
)
)
}
)
)
)
df <- data.frame(
link_text = "Template",
url1 = "https://www.cnn.com/",
url2 = "https://www.bbc.com/news",
two_links = NA)
reactable(df, columns = list(
two_links = colDef(html = TRUE, cell = JS('
function(cellInfo) {
const url1 = ${cellInfo.row["url1"]}
const url2 = ${cellInfo.row["url2"]}
return `<a href="${url1}">cnn</a> <br>
<a href="${url2}">bcc</a>`
}
'))
))
library(tidyverse)
tibble(
link_text = "Template",
link_url = "https://github.com/ddsjoberg/falcon"
) |>
mutate(
markdown = glue::glue("[{link_text}]({link_url})"),
two_links = glue::glue("{markdown}\n\n{markdown}")
) |>
gt::gt() |>
gt::fmt_markdown()Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Backlog