0
A
回答
0
闪亮的转换所有元素为HTML,它不会使新行(\n
)字符。为了创建换行符,可以使用p()
函数将每行包装在一组HTML段落标签中。
这意味着,而是采用renderText()
和textOutput
您需要在您的应用程序使用renderUI
和uiOutput
。
下面给出了如何将换行符转换为段落标签的完整示例。
require(stringi)
require(shiny)
# write text file with standard newline characters
str <- 'These are words\nwith newline characters\n\nthat do not render.'
write(x = str, file = 'Data.txt')
ui <- fluidPage(
h4('Reading raw text from file:'),
textOutput('textWithNewlines'), # text with newline characters output
h4('Converting text to list of paragraph tags'),
uiOutput('textWithHTML') # ui output as a list of HTML p() tags
)
server <- function(input,output){
output$textWithNewlines <- renderText({
rawText <- readLines('Data.txt')
return(rawText)
})
### SOLUTION ###
output$textWithHTML <- renderUI({
rawText <- readLines('Data.txt') # get raw text
# split the text into a list of character vectors
# Each element in the list contains one line
splitText <- stringi::stri_split(str = rawText, regex = '\\n')
# wrap a paragraph tag around each element in the list
replacedText <- lapply(splitText, p)
return(replacedText)
})
}
shinyApp(ui=ui, server=server)
相关问题
- 1. 没有显示在仪表板中的果园内容项目
- 2. 上传文件并在R中显示内容Shiny
- 3. 测量协议事件显示在GA实时仪表板中但不包含内容仪表板
- 4. 在CruiseControl.NET仪表板上的xml文件中显示标记
- 5. Magento仪表板在登录到管理面板后显示仪表板页面,图像和内容不完整
- 6. HangFire仪表板不在PROD中显示
- 7. 在仪表板页面内容中的wordpress更新没有显示
- 8. 在仪表板上显示仪表板使用jQuery中的asp.net c#
- 9. 在Shiny仪表板中更新rCharts nvd3图表
- 10. 在iPad上不显示Bluemix仪表板
- 11. Wordpress插件显示在FTP不在仪表板中
- 12. 在php中显示xml文件内容
- 13. 在dbctrlgrid中显示xml文件内容
- 14. 内容未显示在.vue文件中
- 15. 在Datagridview中显示excel文件内容
- 16. 显示CSV文件内容
- 17. 显示文件内容
- 18. 显示颜色文件中的内容
- 19. 从配置eclipse文件中禁用仪表板,遇到显示仪表板错误
- 20. 在activeadmin仪表板上,试图仅显示未来的事件
- 21. 文件中的文件内容不在php中显示
- 22. Watir显示来自文本文件中的表格的内容
- 23. Django在模板中显示列表的内容
- 24. 如何在salesforce中的visualforce页面中显示仪表板
- 25. Kibana显示空白仪表板
- 26. OpenNMS自定义仪表板不显示
- 27. Wordpress仪表板显示错误
- 28. ActiveAdmin仪表板部分未显示?
- 29. 不显示JIRA仪表盘面板,
- 30. Halogy仪表板不显示图