R:在tableOutput中格式化文本
考虑以下非常简单的闪亮应用程序,它输出存储在数据框R:在tableOutput中格式化文本,r,shiny,format,output,R,Shiny,Format,Output,考虑以下非常简单的闪亮应用程序,它输出存储在数据框df中的文本表: library(shiny) df <- data.frame(id=1:3, text=c('It was a good day today', 'It is good to hear from you', 'I am feeling good'), stringsAsFactors = FALSE) ui <- fluidPage(
df
中的文本表:
library(shiny)
df <- data.frame(id=1:3,
text=c('It was a good day today', 'It is good to hear from you', 'I am feeling good'),
stringsAsFactors = FALSE)
ui <- fluidPage(
tableOutput("freetext")
)
server <- function(input, output){
output$freetext <- renderTable({ df })
}
shinyApp(ui=ui, server=server)
库(闪亮)
df如果使用htmlTable
,则可以在表中包含一些HTML。例如:
library(shiny)
library(htmlTable)
df <- data.frame(
id=1:3,
text=c('It was a <span style="color:red;">good</span> day today',
'It is good to hear from you',
'I am feeling good'),
stringsAsFactors = FALSE)
ui <- fluidPage(
htmlTableWidgetOutput("freetext")
)
server <- function(input, output){
output$freetext <- renderHtmlTableWidget({
htmlTableWidget(df)
})
}
shinyApp(ui=ui, server=server)
库(闪亮)
图书馆(htmlTable)
df如果使用htmlTable
,则可以在表中包含一些HTML。例如:
library(shiny)
library(htmlTable)
df <- data.frame(
id=1:3,
text=c('It was a <span style="color:red;">good</span> day today',
'It is good to hear from you',
'I am feeling good'),
stringsAsFactors = FALSE)
ui <- fluidPage(
htmlTableWidgetOutput("freetext")
)
server <- function(input, output){
output$freetext <- renderHtmlTableWidget({
htmlTableWidget(df)
})
}
shinyApp(ui=ui, server=server)
库(闪亮)
图书馆(htmlTable)
df