2017-04-20 6 views
0

私は、メインパネルにテキストを表示したい光沢のあるアプリを持っています。しかし、TextOutputが機能しないようです。テーブル間にスペースを入れる方法はありますか?ここにコードがあります。時間をいただきありがとうございますTextOutputが光沢で動作していないR

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) 

答えて

1

添付のコードは私に役立ちます。

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) 

問題が解決したことをお知らせください。

関連する問題