如果您想使用renderTable
最简单的方法来设置表格样式,则使用 css。删除行号需要将选项传递include.rownames = FALSE
给print.xtable
. 执行此操作的函数中有一个...
参数renderTable
。您可以在表中包含 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
哪个允许您使用http://datatables.net/。