无法在使用闪亮创建的选项卡中生成选定的数据详细信息

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

我将共享我的ui代码以及服务器代码。请协助如何在创建的数据标签中显示所选数据。

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) 


  })



})

langku 回答:无法在使用闪亮创建的选项卡中生成选定的数据详细信息

除了一个方面,你在所有方面都很好。

在UI.R中,只需在数据TAB中更改为tableOutput("Mydata"),在Server.R中,更改rendertable({})内部的代码,将其更改为get(input$data)

这将是一件好事。当您想在服务器端使用renderTable时,应该使用tableOutput来显示Table

本文链接:https://www.f2er.com/3113432.html

大家都在问