TextOutput在R中不工作
我有一个闪亮的应用程序,我想在主面板中显示文本。但是文本输出似乎不起作用。有没有办法在桌子之间划一条空格线?这是代码。谢谢你抽出时间TextOutput在R中不工作,r,text,shiny,R,Text,Shiny,我有一个闪亮的应用程序,我想在主面板中显示文本。但是文本输出似乎不起作用。有没有办法在桌子之间划一条空格线?这是代码。谢谢你抽出时间 library(DT) ui <- fluidPage( sidebarLayout( sidebarPanel( selectInput("amountTable", "Amount Tables", 1:10), actionButton("submit1" ,"Submit", icon("refresh"),
library(DT)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("amountTable", "Amount Tables", 1:10),
actionButton("submit1" ,"Submit", icon("refresh"),
class = "btn btn-primary"),
actionButton("refresh1" ,"Refresh", icon("refresh"),
class = "btn btn-primary")
),
mainPanel(
# UI output
uiOutput("dt")
)
)
)
server <- function(input, output, session) {
global <- reactiveValues(refresh = FALSE)
observe({
if(input$refresh1) isolate(global$refresh <- TRUE)
})
observe({
if(input$submit1) isolate(global$refresh <- FALSE)
})
observeEvent(input$submit1, {
lapply(1:input$amountTable, function(amtTable) {
output[[paste0('T', amtTable)]] <- DT::renderDataTable({
iris[1:amtTable, ]
})
})
})
observe({
lapply(1:input$amountTable, function(j) {
output[[paste0('Text', j)]] <- renderText({
paste0("This is AmountTable", j)
br() ## add space in between the text and table
})
})
})
output$dt <- renderUI({
if(global$refresh) return()
tagList(lapply(1:10, function(i) {
textOutput(paste0('Text', i))
dataTableOutput(paste0('T', i))
}))
})
}
shinyApp(ui, server)
库(DT)
ui附加的代码对我很有用
library(shiny)
library(DT)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("amountTable", "Amount Tables", 1:10),
actionButton("submit1" ,"Submit", icon("refresh"),
class = "btn btn-primary"),
actionButton("refresh1" ,"Refresh", icon("refresh"),
class = "btn btn-primary")
),
mainPanel(
# UI output
uiOutput("dt")
)
)
)
server <- function(input, output, session) {
global <- reactiveValues(refresh = FALSE)
observe({
if(input$refresh1) isolate(global$refresh <- TRUE)
})
observe({
if(input$submit1) isolate(global$refresh <- FALSE)
})
observeEvent(input$submit1, {
lapply(1:input$amountTable, function(amtTable) {
output[[paste0('T', amtTable)]] <- DT::renderDataTable({
iris[1:amtTable, ]
})
})
})
observeEvent(input$submit1, {
lapply(1:input$amountTable, function(j) {
output[[paste0('Text', j)]] <- renderText({
paste0("This is AmountTable", j)
# br() ## add space in between the text and table
})
})
})
output$dt <- renderUI({
if(global$refresh) return()
tagList(lapply(1:input$amountTable, function(i) {
list(textOutput(paste0('Text', i)),br(),
dataTableOutput(paste0('T', i)))
}))
})
}
shinyApp(ui, server)
库(闪亮)
图书馆(DT)
用户界面