appliedepi / appliedepidata

This package stores all Applied Epi data across courses and resources.
https://appliedepi.github.io/appliedepidata/
GNU General Public License v3.0
0 stars 0 forks source link

update available-data.Rmd table #9

Closed aspina7 closed 3 weeks ago

aspina7 commented 1 month ago

can add links within reactable to link to cross link language. In this way can just have the english language table, and then the "en", "fr", etc in the language cell become individual links to the package dataset documentation pkgdown site for that language.

Not convinced the below code example will work - also see this stackoverflow answer

# Define the base URL of your pkgdown website
pkgdown_url <- "https://yourpkgwebsite.com/reference/"

# Create a function to generate links for each language
create_language_links <- function(dataset_name, languages) {
  language_list <- strsplit(languages, ", ")[[1]]

  # Create HTML anchor tags with links to dataset documentation
  language_links <- sapply(language_list, function(lang) {
    dataset_doc <- paste0(pkgdown_url, dataset_name, "_", lang, ".html")
    paste0("<a href='", dataset_doc, "' target='_blank'>", lang, "</a>")
  })

  # Combine all the language links
  paste(language_links, collapse = ", ")
}

# Add a column to dataset_info with the clickable language links
dataset_info$language_links <- mapply(create_language_links, dataset_info$dataset_name, dataset_info$languages)

# Render the reactable
reactable(
  dataset_info,
  columns = list(
    dataset_name = colDef(name = "Dataset Name"),
    language_links = colDef(name = "Languages", html = TRUE)
  )
)
aspina7 commented 1 month ago

Other things to check (last one probably most relevant)

https://glin.github.io/reactable/articles/cookbook/cookbook.html#insert-links

https://forum.posit.co/t/r-shiny-create-a-column-in-reactable-table-that-includes-a-hyperlink/96842/5

https://glin.github.io/reactable/articles/examples.html#cell-rendering