Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make bold text in HTML output R shiny

Tags:

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)...

like image 980
Antoine Avatar asked Oct 28 '15 13:10

Antoine


People also ask

What is shiny tag?

shiny::tags is a list of 110 functions. Each function builds a specific HTML tag. If you are familiar with HTML, you will recognize these tags by their names. You can build UI by using HTML tags.

How do I make text bold in R shiny?

Shiny has many functions that can transform plain text into formatted text. Simply place text inside the h1() function to create a primary header (e.g. a title), h2() for a secondary header, strong() to make text bold, em() to make text italicized, or any of the other formatting functions.

How do you make text bold in HTML?

To bold the text in HTML, use either the strong tag or the b (bold) tag. Browsers will bold the text inside both of these tags the same, but the strong tag indicates that the text is of particular importance or urgency. You can also bold text with the CSS font-weight property set to “bold.”


1 Answers

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))     })   } )) 
like image 92
Sebastian Avatar answered Sep 21 '22 17:09

Sebastian