gpt4 book ai didi

html - 使 HTML 输出 R 中的粗体文本 Shiny

转载 作者:bug小助手 更新时间:2023-10-28 10:46:26 26 4
gpt4 key购买 nike

可重现的例子:

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")))
})
}
))

我希望索引对应的单词(默认为“raccoon”)以粗体显示,其他单词以普通字体显示。

如果我这样做:

HTML(
<b>paste(c("banana","raccoon","duck","grapefruit")[input$index])<\b>,
paste(c("banana","raccoon","duck","grapefruit")[setdiff(1:4,input$index)])
)

我收到一个错误(< 无法识别)...

最佳答案

再试一次,有用吗?

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 - 使 HTML 输出 R 中的粗体文本 Shiny ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33392784/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com