How to add each stock daily price in a banner (marquee) in navbarpage rshiny

Viewed 40

Good mornning. I am working with financial data (daily prices of some stocks) I would like to insert in a banner/marquee efficient way the information about the current prices of the shares of the listed companies as shown in the following picture. Refer to the image enter image description here and the link

Below is my code Thanks in advance

library(shiny)
library(shinydashboard)
library(shinythemes)
library(bslib)

##The information i want to display in the banner
qt <- list(Symbole = c("ABJC", "BICC", "BNBC", "BOAB", "BOABF", "BOAC", "BOAM", "BOAN", 
                       "BOAS", "CABC", "CBIBF", "CFAC", "CIEC", "ECOC", "ETIT", "FTSC", 
                       "NEIC", "NSBC", "NTLC", "ONTBF", "ORGT", "PALC", "PRSC", "SAFC", 
                       "SCRC", "SDCC", "SDSC", "SEMC", "SGBC", "SHEC", "SIBC", "SICC", 
                       "SIVC", "SLBC", "SMBC", "SNTS", "SOGC", "SPHC", "STAC", "STBC", 
                       "SVOC", "TTLC", "TTLS", "TTRC", "UNLC", "UNXC"),
           `Cours cloture (FCFA)` = c(1600, 5855, 2200, 5650, 6140, 5310, 1380, 5145, 2500, 1190, 
                                      9750, 1160, 2150, 4675, 23, 1700, 740, 5755, 5275, 4195, 3905, 
                                      7505, 4715, 850, 920, 4450, 2500, 735, 11200, 980, 3985, 4865, 
                                      775, 165000, 7080, 14150, 5000, 5100, 1440, 5850, 0, 2245, 2050, 
                                      0, 0, 2055),
           `Variation(%)` = c("1,54", "-6,91", "0", "0", "0,16", "-0,94", "-1,09", "-0,78", 
                              "-2,72", "0", "0,3", "0", "-2,33", "0", "0", "2,41", "7,25", 
                              "0", "0", "0", "-0,64", "1,96", "-7,29", "6,51", "2,17", "0", 
                              "-0,97", "0", "0", "0", "-1,27", "0,31", "-7,1", "0,61", "0,07", 
                              "0,71", "1,41", "-0,38", "7,29", "-0,08", "0", "0,67", "0", "0", 
                              "0", "0,48")
)  

qt <- as_tibble(qt)

#A vector contening element of each stock
aaa1 <- NULL
for (i in 1 : nrow(qt)){
  aaa1 <- append(aaa1, paste0(qt[i, ], collapse = " "))
}

##aaa1 is the information i really want to display in my banner
#head(aaa1)
# [1] "ABJC 1600 1,54"  "BICC 5855 -6,91" "BNBC 2200 0"     "BOAB 5650 0"    
# [5] "BOABF 6140 0,16" "BOAC 5310 -0,94"


shinyOptions(bslib = TRUE)
bs_global_theme()
bs_theme_base_colors(bg = "#002B36", fg = "#EEE8D5")
bs_theme_accent_colors(primary = "#2AA198")
thematic::thematic_shiny()
theme=shinytheme("cerulean")# returns URL of a shiny theme
themeSelector() ## not required but can be used to select the theme

#My shiny app is similar to this one
ui <- fluidPage(
  theme=shinytheme("cerulean"),# returns URL of a shiny theme
  themeSelector(), ## not required but can be used to select the theme
  navbarPage(
    title= "BRVM stock exchange", position = "static-top", id="nav",
    tabPanel("Introduction", value = "Introduction", icon = icon("info-circle")),
             
  # Application title
  tabPanel("Stocks market Shiny!",
  sidebarLayout(
    
    # Sidebar with a slider input
    sidebarPanel(
      sliderInput("obs",
                  "Number of observations:",
                  min = 0,
                  max = 1000,
                  value = 500)
    ),
    
    # Show a plot of the generated distribution
    mainPanel(  
      tabsetPanel(
      tabPanel("About society",icon = icon("address-card", class="fa-regular fa-address-card"),
               plotOutput("distPlot"),
               ),
      tabPanel("Data summary",icon = icon("table"),
               verbatimTextOutput("summary")),
      tabPanel("Forcast", "Forcast", icon = icon("list-alt"),
               plotOutput("dplot"))
      )
      
    ) #main
  )
)))

# Server logic
server <- function(input, output) {
  cs <- new.env()
  output$distPlot <- renderPlot({
    hist(rnorm(input$obs))
  })
  output$summary <- renderPrint({
  ok <- summary(rnorm(500))
  ok
})
  output$dplot <- renderPlot({
    plot(rnorm(input$obs))
  })
  
}


shinyApp(ui, server)
0 Answers
Related