R:使用'FluidRow()时生成指向列中数据的HTML链接`

R:使用'FluidRow()时生成指向列中数据的HTML链接`,r,shiny,R,Shiny,我使用R包显示表格数据。我希望将一列中的值显示为HTML链接,可用于导航到另一个页面 我该怎么做 Paul K如果您的某个列有链接,您可以向其中添加HTML链接标记,并将其显示在数据表中: server <- function(input, output) { #create dummy data data <- data.frame(links=c("http://www.google.com","http://www.google.com")) #add html l

我使用R包显示表格数据。我希望将一列中的值显示为HTML链接,可用于导航到另一个页面

我该怎么做


Paul K

如果您的某个列有链接,您可以向其中添加HTML链接标记,并将其显示在数据表中:

server <- function(input, output) {
  #create dummy data
  data <- data.frame(links=c("http://www.google.com","http://www.google.com"))
  #add html link tags
  data$links <- paste0("<a href='",data$links,"'>",data$links,"</a>")

  #render datatable
  output$table <- renderDataTable(data,escape=FALSE)
}

ui <- fluidPage(
  fluidRow(dataTableOutput(outputId="table"))
)

shinyApp(ui = ui, server = server)

您应该提供一个可复制的示例来展示您已经尝试过的内容,以便其他人更容易理解您的问题并帮助您。好吧,据我所知,没有什么可以尝试的,因为数据显示在一行中,例如
fluidRow(dataTableOutput(outputId=“table”)
。所以我想知道是否有一种方法可以公开这个函数的内部。非常感谢。它起作用了,但我必须确保导入的数据带有明确定义的分隔符(sep=“\t”),以便

Added an `escape` argument to `renderDataTable()` to escape the HTML entities
  in the data table for security reasons. This might break tables from previous
  versions of shiny that use raw HTML in the table content, and the old behavior
  can be brought back by `escape = FALSE` if you are aware of the security
  implications. (#627)