在HTML输出中使粗体文本R闪亮 [英] Make bold text in HTML output R shiny
问题描述
$ $ 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 < - renderUI({
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 <-c(banana,raccoon,duck,grapefruit)
$ 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闪亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!