renderPrint option in ShinyApp

穿精又带淫゛_ 提交于 2020-02-24 14:01:30

问题


I'm using the renderPrint function in a ShinyApp to show calculation results. The results come with a [1],[2] etc in front.

Is there a way to get rid of that?

Also, can one change fonts of the output?


回答1:


You could use renderText instead of renderPrint. Or maybe withMathJax() could also be an option?

For styling your app, there are several ways to do that. You can read about that here. I include the css directly in the app in the following example. For small adaptations thats maybe the easiest way, for more complex apps, I would use a css file and include it with includeCSS("www/style.css") or 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)


来源:https://stackoverflow.com/questions/50781653/renderprint-option-in-shinyapp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!