I have created a dependent column in my code, the critical requirement is when user select the filter option it should show the bar plot for the option.
As per the code I want to achieve following. If you run my code and select "Americas" in first drop down "Region". The second drop down has "Mexico" and and the third drop down has "HR"
When I compile the code it shows up two bar plot. I want to compare the all the ratings / values of "Rating" and "Rating1" (Value field in the code) with all the value in the bar plot
The Value of the fields are "Rating", "Rating1"
Ui.R
library(shiny)
ui <- fluidPage(
titlePanel(title = h2("Program Manager Dashboard ")),
sidebarLayout(
sidebarPanel(
uiOutput("data1"), ## uiOutput - gets the UI from the server
uiOutput("data2"),
uiOutput("data3")
),
mainPanel(
plotOutput("plot")
)
))
Server.R
library(shiny)
shinyServer(function(input, output, session) {
Region<- c("Americas", "Asia Pacific","Asia Pacific", "EMEA", "EMEA","EMEA","Americas", "Americas")
Country<- c("Mexico", "China","India", "Germany", "Spain","Spain","Mexico", "Mexico" )
Function<-c("HR", "Finance", "IT","IT","IT","IT", "HR", "HR")
Rating<- c(5,3,4,2,4,3, 1, 4)
Rating1<- c(4,5,1,5,5,5,5, 4)
book3<- data.frame(Region, Country, Rating, Rating1,Function, stringsAsFactors = F)
output$data1 <- renderUI({
selectInput("data1", "Select Region", choices = c(book3$Region), selected = Region["Americas"] )
})
output$data2 <- renderUI({
selectInput("data2", "select Country", choices = book3[which(book3$Region == input$data1),]$Country)
})
output$data3<-renderUI({
selectInput("data3", "Select Function", choices = book3[which(book3$Country==input$data2),]$Function)
})
barplot(book3$Rating,book3$Country==input$data2, ylim=c(0,5), xlim=c(0,2), width=0.2, col=c("darkblue","red"), xlab = "Customer Feedback")
})
})