问题
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