【发布时间】:2018-11-19 18:07:18
【问题描述】:
我在 ShinyApp 中使用renderPrint 函数来显示计算结果。结果前面带有[1],[2] 等。
有没有办法摆脱它?
另外,可以改变输出的字体吗?
【问题讨论】:
标签: r shiny shiny-server shinyapps
我在 ShinyApp 中使用renderPrint 函数来显示计算结果。结果前面带有[1],[2] 等。
有没有办法摆脱它?
另外,可以改变输出的字体吗?
【问题讨论】:
标签: r shiny shiny-server shinyapps
您可以使用renderText 代替renderPrint。或者withMathJax() 也可以是一个选项?
要为您的应用设置样式,有多种方法可以做到这一点。你可以阅读here。在以下示例中,我将 css 直接包含在应用程序中。对于小型改编,这可能是最简单的方法,对于更复杂的应用,我会使用 css 文件并将其包含在 includeCSS("www/style.css") 或 tags$head(tags$style("www/style.css")) 中。
library(shiny)
ui <- fluidPage(
tags$head(
tags$style(HTML("
#renderprint {
color: white;
background: blue;
font-family: 'Times New Roman', Times, serif;
font-size: 20px;
font-style: italic;
}
#rendertext {
color: blue;
background: orange;
font-family: 'Times New Roman', Times, serif;
font-size: 12px;
font-weight: bold;
}
#rendertext1 {
color: red;
background: yellow;
font-family: Arial, Helvetica, sans-serif;
font-size: 19px;
}
"))
),
verbatimTextOutput("renderprint"),
verbatimTextOutput("rendertext"),
textOutput("rendertext1")
)
server <- function(input, output, session) {
output$renderprint <- renderPrint({
print("This is a render Print output")
})
output$rendertext <- renderText({
"This is a render Text output - with verbatimTextOutput"
})
output$rendertext1 <- renderText({
"This is a render Text output - with textOutput"
})
}
shinyApp(ui, server)
【讨论】: