RenderUI issues with userBox

Hello Everyone,

I am attempting to create a userBox (package: ShinyDashboardPlus) in a RShiny dashboard using a uiOutput in the UI function. My primary issue is that I could like the userBox to update based on what athlete is selected in a selectInput. As a result, I would also like their picture to update.

Here is a brief sample of my data frame:

'''

 PlayerName <- c("Alexander Ovechkin", "Sidney Crosby")
 Position <- c("Forward", "Forward")
 ImageURL <- c("https://cms.nhl.bamgrid.com/images/headshots/current/168x168/8471214.jpg", "https://cms.nhl.bamgrid.com/images/headshots/current/168x168/8471675.jpg")

    DF <- data.frame (PlayerName, Position, ImageURL)

'''

Below is sample of my code:

UI

'''

  ui <-navbarPage(title=title, 

    tabPanel(title = "HOME",icon= icon("Home"),
      fluidPage(
      fluidRow(column(3,
                h4("Filter Data", align = "center"),
                    box(collapsible = FALSE,
                        width= 12,
                        selectInput( "Playernameinput", "Select Player", choices = DF$PlayerName)
),
              column(3, 
                h4("Selected Athlete", align = "center"),
                uiOutput("SelectedAthletePlaceHolder")

 )))

'''

Below is the Server:

'''

server <- function(session, input, output) {

output$SelectedAthletePlaceHolder <- renderUI({
                                              req(input$Playernameinput)
  
                                              req(PlayerPositionFilter <- DF %>% 
                                                                          filter(`PlayerName` %in% input$Playernameinput),
                                                  PlayerPosition <- PlayerPositionFilter$Position)
                                              
                                              req(PlayerImageFilter <- DF %>%
                                                                       filter(`Playername` %in% input$Playernameinput),
                                                  PlayerImage <- PlayerImageFilter$ImageURL)
                                                
                                              userBox(title = userDescription(title=input$Playernameinput,
                                                                              subtitle = PlayerPosition,
                                                                              type=2, 
                                                                              background = "Red", 
                                                                              image= PlayerImage), 
                                                      width = 12)


 }

'''

This userBox so far works as expected with the Player Name and the Position updating in the title based on the input of the Playernameinput. However, the Image aspect does not update correctly. I have not noticed an error message, but a small question mark appears rather than the image its self. Note that if I hard code the URL into the image function, this works correctly.

I am sure I am missing a small factor.

Any assistance in this area of general input on my code would be very much appreciated! Thank you for your time and effort.

I can't reproduce your issue. I find you have another error, that results in explicit red text error message, due to malformed filter expression. You use dplyr::filter twice, once with correct capitalisation of PlayerName and once incorrect Playername. Once I fixed that your app worked fine for me and altered image shown on demand.
Also you did not share the content of the navbar title, which was an annoying thing for me to debug (why isnt this persons app even working at all ?)

1 Like

Thank you very much! Sorry for the issues with the title

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.