0
votes

I have started practicing shiny package for making dashboard, and i am still an amateur at R, please help me to display the data which will be selected using selectinput in the allocated tab which i have created for display of data.

I shall share my ui code as well as server code. Please assist how to display selected data in the data tab created.

ui.R code


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 code


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) 


  })



})

1

1 Answers

0
votes

you are good in all point except one.

In the UI.R, in Data TAB just change to tableOutput("Mydata") and in Server.R change the code inside rendertable({}) change it to get(input$data).

It will be good to go. You should use tableOutput for displaying Table when you want to use renderTable in server side