【问题标题】:Unable to generate selected data details in tab created using shiny无法在使用闪亮创建的选项卡中生成选定的数据详细信息
【发布时间】:2019-11-13 00:55:17
【问题描述】:

我已经开始练习制作仪表板的闪亮包,我仍然是 R 的业​​余爱好者,请帮助我显示将在我为显示数据创建的已分配选项卡中使用 selectinput 选择的数据。

我将分享我的用户界面代码以及服务器代码。请协助如何在创建的数据选项卡中显示所选数据。

ui.R 代码


library(shiny)
library(shinydashboard)


shinyUI(fluidPage(

  titlePanel(h1("Test for application of all the tutorials completed till now")),


  sidebarLayout(

    sidebarPanel((h2("Information Panel Enter")),


                 selectInput("data", "Select the dataset for hist analysis", 

                             choices = c("iris","pressure","USArrests", selected = "pressure")),


                 numericInput("obs", "Select the number of observations for the dataset", value = 5,min = 5,max = 30,step = 1 ),


                 sliderInput("bins", "Select the number of bins for histogram", value = 6, min = 6, max = 20, step = 1),


                 radioButtons("color", "selecct the color of histogram" , choices = c("black","purple","brown"))),



    mainPanel((h3("Main Panel of all the information display")),

              tabsetPanel(type = c("pills"),

                          tabPanel("Summary" , h4(textOutput("Mysumhead")) ,verbatimTextOutput("Mysum")),

                          tabPanel("Structure and Observation" , h4(textOutput("Mystrhead")), verbatimTextOutput("Mystr")),

                          tabPanel("Plot"),

                          tabPanel("Data" , verbatimTextOutput("Mydata"))))

)))


server.R 代码


library(shiny)
library(shinydashboard)
library(datasets)

shinyServer(function(input,output){


  output$Mysum <- renderPrint({

    summary(get(input$data))

  })


  output$Mysumhead <- renderText({

    paste("Data Selected for checking summary is " , input$data)

  })


  output$Mystr <- renderPrint({


    str(get(input$data))


  })

  output$Mystrhead <- renderText({

    paste("Data selected for observing summary of the data is " , input$data)

  })


  output$Mydata <- renderTable({

      data(input$data) 


  })



})

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案1】:

    除了一个,你什么都好。

    在 UI.R 中,在 Data TAB 中更改为 tableOutput("Mydata"),在 Server.R 中将 rendertable({}) 中的代码更改为 get(input$data)

    去就好了。当你想在服务器端使用 renderTable 时,你应该使用 tableOutput 来显示 Table

    【讨论】:

    • 谢谢 Subhasish 1315 先生,它成功了,完美地完成了我想要的 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-06
    • 1970-01-01
    相关资源
    最近更新 更多