首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ShinyApp中的renderPrint选项

ShinyApp中的renderPrint选项
EN

Stack Overflow用户
提问于 2018-06-10 15:55:06
回答 1查看 4.6K关注 0票数 2

我在ShinyApp中使用renderPrint函数来显示计算结果。结果会在前面加上一个[1],[2]等。

有没有办法摆脱它?

另外,可以更改输出的字体吗?

EN

回答 1

Stack Overflow用户

发布于 2018-06-10 21:20:54

您可以使用renderText而不是renderPrint。或者也许withMathJax()也可以是一个选择?

对于应用程序的样式,有几种方法可以做到这一点。您可以阅读有关该here的内容。在下面的示例中,我将css直接包含在应用程序中。对于小的调整,这可能是最简单的方法,对于更复杂的应用程序,我会使用css文件,并将其包含在includeCSS("www/style.css")tags$head(tags$style("www/style.css"))中。

代码语言:javascript
复制
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)
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50781653

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档