I am using the following two Input functions code in shiny:
selectInput("categoryVisu", label="SELECT CATEGORY", choices = list("Full" = "full", "Fact" = "fact", "Fact Positive" = "factpos", selected = "full", multiple = TRUE)
and
selectInput("investerVisu", label="SELECT INVESTOR", choices = list("Informed" = "inf", "Noise" = "noise"), selected = "inf", multiple = TRUE)
My task is now, if the user select for example "Full" and "Informed" than my code should take the column "InformedFull" from my dataset to print the code. How can I handle this? My DataSet looks like this:
Dataset
I already did the ggplot code, that looks like this:
ggplot(data = OLS.Data, aes(x=OLS.Data$Date, y=...))+geom_line()
So where I placed the ... their should be based on the booth selection of my selectInput, be the correct column of my dataset.
My UI Boxes looking like this:
tabItem(tabName = "visu",
fluidRow(
box(
title = "Controls-1",
status = "primary",
solidHeader = TRUE,
width = 3,
selectInput("categoryVisu", label="SELECT CATEGORY", choices = list("Full" = "Full", "Fact" = "Fact", "Fact Positive" = "Fact.Pos", "Fact Negative" = "Fact.Neg", "Emotions" = "Emotions", "Emotions Fact" = "EmotionsFact"), selected = "Full", multiple = TRUE)
),
box(
title = "Controls-2",
status = "primary",
solidHeader = TRUE,
width = 3,
selectInput("investerVisu", label="SELECT INVESTOR", choices = list("Informed" = "Informed", "Noise" = "Noise"), selected = "Informed", multiple = TRUE)
),
And my server file:
server <- function(input, output) {
observeEvent(input$categoryVisu,{
partA<-input$catagoryVisu
partA<-as.character(partA)
})
observeEvent(input$investerVisu,{
partB<-input$investerVisu
partB<-as.character(partB)
})
partC<-paste(partB,partA)
DataFus<-OLS.Data$partC
output$myPlot <- renderPlot({
ggplot(data = OLS.Data, aes(x=OLS.Data$Date, y=OLS.Data$NYSE))+geom_line()+geom_line(data = OLS.Data,aes(x=OLS.Data$Date, y=DataFus),color="red")+geom_line(alpha = input$alphaVisu)
})
}
See Question&Answers more detail:
os