I’m working on an App that generates large amounts of text in response to user definitional questions. I’m coding text in using HTML in separate modules, and it is becoming very cumbersome to code in all this text mainly due to the HTML coding conventions. Is there a simplified way to pull in the text of a Word document, including formats, into the UI section of a Shiny App, instead of manually coding in all text in HTML? Below is a super-simple example code of my current approach, I wonder if there’s an easier approach than what I’m doing in the HTML()
function in the server()
section:
library(shiny)
ui <- fluidPage(uiOutput("coxModel"))
server <- function(input, output) {
output$coxModel <- renderUI(
tags$div(
style="text-align:justify",
HTML(
"<b>Select</b> from <i>`Multiple-predictors for Cox model`</i> menu to run Cox model.",
)
)
)
}
shinyApp(ui, server)
2
Answers
The cleanest solution for me is to follow limey's suggestion where I:
Here is the code for this solution:
Adapting ismirsehregal's comment, I did the following:
HTML()
functionAnd it renders correctly!
Here's the revised code:
Here's the code that was revealed when I right-clicked on the HTML file:
You can use shiny tags like so:
Also, if none of the elements being rendered has interactivity, I’d recommend you put it all in the UI. Like this: