Make bold text in HTML output R shiny

formatting, html, r, shiny

Solution

One more try, is this helpful?

require(shiny)

fruits <- c("banana","raccoon","duck","grapefruit")

runApp(list(ui = pageWithSidebar(
  headerPanel("Example"),
  sidebarPanel(
    sliderInput("index", 
                label = "Select a number",
                min = 1,
                max = 4,
                step = 1,
                value = 2)),
  mainPanel(
    htmlOutput("text")
  )),
  server = function(input, output) {
    output$text <- renderUI({
      fruits[input$index] <- paste("<b>",fruits[input$index],"</b>")
      HTML(paste(fruits))
    })
  }
))

Problem

Reproducible example: ``` require(shiny) runApp(list(ui = pageWithSidebar( headerPanel("Example"), sidebarPanel( sliderInput("index", label = "Select a number", min = 1, max = 4, step = 1, value = 2)), mainPanel( htmlOutput("text") )), server = function(input, output) { output$text <- renderUI({ HTML(paste(c("banana","raccoon","duck","grapefruit"))) }) } )) ``` I would like to have the word corresponding to index ("raccoon" in the default) displayed in bold and the other words in normal font. If I do: ``` HTML( <b>paste(c("banana","raccoon","duck","grapefruit")[input$index])<\b>, paste(c("banana","raccoon","duck","grapefruit")[setdiff(1:4,input$index)]) ) ``` I receive an error (`<` is not recognized)...

Original source