Reputation: 133
In my Markdown file I use Shiny widgets to set some parameter. Add the end of the document some reactive text should be shown, depending on the choosen parameter, changing when a parameter is changed. This text should be formatted with linebreaks. Output format is HTML. The following minimal example shows my approach, the screenshot below the outcome. Unfortunatelly without linebreaks.
How can I archieve linebreaks in reactive textoutput in R-Markdown?
---
title: 'Minimal example'
runtime: shiny
output:
html_document
---
```{r setup, include=FALSE}
library(knitr)
library(shiny)
knitr::opts_chunk$set(echo = F)
```
```{r}
selectInput("input1", label = "Input1",
choices = 1:5, selected = 1)
selectInput("input2", label = "Input2",
choices = 1:5, selected = 1)
```
```{r}
### Generate Parameter for report
renderText({
HTML(paste('Input1:', input$input1, '<br> Input2:', input$input2))
})
renderText({
paste('Input1:', input$input1, ' \\n Input2:', input$input2)
})
renderText({
paste('Input1:', input$input1, ' \n Input2:', input$input2)
})
renderText({
cat(paste('Input1:', input$input1, ' \n Input2:', input$input2))
})
```
Upvotes: 1
Views: 1688
Reputation: 23919
Use renderUI
in combination with HTML()
instead:
renderUI({
HTML(paste('Input1:', input$input1, '<br> Input2:', input$input2))
})
Upvotes: 2