In the process of creating some reactive expressions with Shiny in R and with some help from the community, I'm able to obtain reactive results via text. I'm interested in passing through figures that would correspond to the text via the profiles. In the example below, I have the input "myImage" in mainPanel in ui. On the server side I'm attempting to call naomi.png for a specific conditional statement that corresponds to Profile 3. The idea is to have one .png associated with each #Profile X that gets called on the server side given the object "profile". Any pointers/starters would be appreciated.
ui<-(fluidPage(
titlePanel("Diagnostic Elementary Reading fluency Profile (DERP) App"),
sidebarLayout(
sidebarPanel(
helpText("Enter Fluency Scores"),
sliderInput(inputId="fluency1", label="Fall FSF",value=25,min=0,max=50),
sliderInput(inputId="fluency2", label="Fall LNF",value=25,min=0,max=50)
),
mainPanel(img(src="myImage",height=300,width=400),
h1(textOutput("stuff")),align="center"))
)
)
server<-function(input,output) {
profile <- reactive({
if ( (input$fluency2<20.5)) {
tmp <- "Profile 1"
}
if( (input$fluency1<12) & ((input$fluency2>20)) & (input$fluency2<23)) {
tmp <- "Profile 1"
}
if( (input$fluency1<9) & ((input$fluency2>21)) & (input$fluency2<25)) {
tmp <- "Profile 1"
}
#PROFILE 2
if ( (input$fluency1>11)) {
tmp <- "Profile 2"
}
if( ((input$fluency1>8) & (input$fluency1<28)) & ((input$fluency2>22) & (input$fluency2<25))) {
tmp <- "Profile 2"
}
if( (input$fluency1<28) & ((input$fluency2>24))) {
tmp <- "Profile 2"
}
#PROFILE 3
if( (input$fluency1>27) & ((input$fluency2>23))) {
tmp <- "Profile 3"
}
tmp
})
output$stuff <- renderText({
profile()
})
output$myImage<-renderImage({
if( (input$fluency1>27) & ((input$fluency2>23))) {
return(list(
src = "www/naomi.png",
contentType = "image/png",
alt = "naomi!"))}
})
}
shinyApp(server=server,ui=ui)
"www/naomi.png") based on a number of conditionals or if statements? - Adrian