我已经开始练习用于制作仪表盘的闪亮包装,但我仍然是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)
})
})