本文介绍了在HTML输出中使粗体文本R闪亮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 可复制的例子: $ $ p $ require(shiny) runApp(list(ui = pageWithSidebar( headerPanel(Example), sidebarPanel( sliderInput(index, label =选择一个数字, min = 1, max = 4 , step = 1, value = 2)), mainPanel( htmlOutput(text))), server = function输入,输出){输出$ text HTML(paste(c(banana,raccoon,duck,grapefruit))) })} )) 我想要相应的字在粗体中显示索引(默认为raccoon),其他词以正常字体显示。如果我这样做: (b)(c(香蕉,浣熊,鸭,葡萄柚),b $ b )[input $ index]), paste(c(banana,raccoon,duck,grapefruit)[setdiff(1:4,input $ index)] )) 我收到一个错误(< 不被识别)... 解决方案 pre $ require(shiny) fruits $ b $ runApp(list(ui = pageWithSidebar( headerPanel(Example), sidebarPanel( sliderInput(index, label =Select一个数字, min = 1, max = 4, step = 1, value = 2)), mainPanel( htmlOutput text))), server = function(input,output){ output $ text< - renderUI({ fruits [input $ index]<粘贴(< b>,fruits [输入$索引],< / b>) HTML(粘贴(水果))})} )) 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)... 解决方案 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)) }) })) 这篇关于在HTML输出中使粗体文本R闪亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!