Html 自建表,有光泽

Html 自建表,有光泽,html,r,shiny,shiny-server,Html,R,Shiny,Shiny Server,我想知道我怎样才能创建一个html表格单元格的单元格与动态内容在闪亮? 现在我正在使用以下组合: server.R output$desc <- renderTable( hdx.desc() ) ui.R tabsetPanel( tabPanel("Description", tableOutput("desc")) ) 这很有效。我想设置一些单元格的链接,并在表格中添加一些额外的布局设置,如粗体、无边框等,也不想在前面添加行号 我该怎么做?我尝试了HTML命令,但没有

我想知道我怎样才能创建一个html表格单元格的单元格与动态内容在闪亮? 现在我正在使用以下组合:

server.R

output$desc <- renderTable(
  hdx.desc()
)

ui.R

tabsetPanel(
  tabPanel("Description", tableOutput("desc"))
)
这很有效。我想设置一些单元格的链接,并在表格中添加一些额外的布局设置,如粗体、无边框等,也不想在前面添加行号

我该怎么做?我尝试了HTML命令,但没有成功。 感谢您的帮助。

如果您想使用可渲染,最简单的表格样式设置方法是使用css。删除行号需要将include.rownames=FALSE选项传递到print.xtable。有一个。。。执行此操作的可渲染函数中的参数。您可以在表中包含html并使用sanitize.text.function参数

runApp(list(
  ui = bootstrapPage(
    tableOutput("myTable")
    , tags$head(tags$style(type="text/css", 
"#myTable table th td {
border: 1px solid black !important;
}
#myTable table th
{
background-color:green;
color:white;
}"
))

  ),
  server = function(input, output) {
    output$myTable <- renderTable({ 
      temp = c(runif(4), 
               as.character(tags$a(id = 'myId', href='http://www.example.com', runif(1)))
               )
      data.frame(date=seq.Date(Sys.Date(), by=1, length.out=5), temp = temp)
      }, include.rownames = FALSE, sanitize.text.function = function(x) x)
  }
))
或者看看renderDataTable,它允许您使用。

如果您想使用renderTable,设置表格样式的最简单方法是使用css。删除行号需要将include.rownames=FALSE选项传递到print.xtable。有一个。。。执行此操作的可渲染函数中的参数。您可以在表中包含html并使用sanitize.text.function参数

runApp(list(
  ui = bootstrapPage(
    tableOutput("myTable")
    , tags$head(tags$style(type="text/css", 
"#myTable table th td {
border: 1px solid black !important;
}
#myTable table th
{
background-color:green;
color:white;
}"
))

  ),
  server = function(input, output) {
    output$myTable <- renderTable({ 
      temp = c(runif(4), 
               as.character(tags$a(id = 'myId', href='http://www.example.com', runif(1)))
               )
      data.frame(date=seq.Date(Sys.Date(), by=1, length.out=5), temp = temp)
      }, include.rownames = FALSE, sanitize.text.function = function(x) x)
  }
))

或者查看允许您使用的renderDataTable。

如果您知道您的表是静态的,并且只有内容是动态的,那么您可以按照我在此处注释的方法操作: 简言之,我构建了一个静态html表,并将其封装在一个单独的R文件中的函数中,在服务器中获取它的源代码,然后在renderUI函数中使用新过滤的数据调用它。因此,表内容会随着用户输入而更新


未来的项目将是一个允许用户以动态方式生成静态html表的函数,例如,一个创建包含X行、Y列、rownames[]、colnames[]等的表的函数。如果我成功,我将在此处发布我的解决方案。

如果您知道您的表是静态的,并且只有内容是动态的,您可以遵循我在此处注释的方法: 简言之,我构建了一个静态html表,并将其封装在一个单独的R文件中的函数中,在服务器中获取它的源代码,然后在renderUI函数中使用新过滤的数据调用它。因此,表内容会随着用户输入而更新


未来的项目将是一个允许用户以动态方式生成静态html表的函数,例如,一个创建包含X行、Y列、rownames[]、colnames[]等的表的函数。如果我成功,我将在此处发布我的解决方案。

感谢您的建议。当我将您的想法应用到我的问题输出$desc时,您需要在renderable中返回x。您还更改了sanitize.text.function的定义。感谢您的建议。当我将您的想法应用到我的问题输出$desc时,您需要在renderable中返回x。您还更改了sanitize.text.function的定义。