R:在几行上显示文本作为代码
我想在我闪亮的应用程序上显示一些R代码。因此,我使用了R:在几行上显示文本作为代码,r,shiny,R,Shiny,我想在我闪亮的应用程序上显示一些R代码。因此,我使用了逐字输出,但我找不到一种方法来断行和显示代码的段落 此解决方案()仅适用于HTML函数,据我所知,无法将逐字输出和htmlOutput混合使用 我可以显示带有标签$code的代码,但它不是我想要的外观(我更喜欢灰色背景) 下面是一个可复制的示例: library(shiny) ui <- fluidPage( mainPanel(htmlOutput("base", placeholder = FALSE)
逐字输出
,但我找不到一种方法来断行和显示代码的段落
此解决方案()仅适用于HTML
函数,据我所知,无法将逐字输出
和htmlOutput
混合使用
我可以显示带有标签$code
的代码,但它不是我想要的外观(我更喜欢灰色背景)
下面是一个可复制的示例:
library(shiny)
ui <- fluidPage(
mainPanel(htmlOutput("base", placeholder = FALSE)
)
)
server <- function(input, output) {
output$base <- renderUI({
tags$code(HTML(paste("just", "some", "code", sep = '<br/>')))
})
}
shinyApp(ui = ui, server = server)
库(闪亮)
ui我以前曾为此使用过cat()
:
library(shiny)
ui <- fluidPage(
mainPanel(verbatimTextOutput("vtout"))
)
server <- function(input, output) {
output$vtout <- renderPrint({
cat("just", "some", "code", sep = "\n")
})
}
shinyApp(ui, server)
库(闪亮)
ui谢谢,我以前没想过使用renderPrint