【发布时间】:2018-11-04 16:23:46
【问题描述】:
我正在尝试使用 Shiny 在 R 中编写一个简单的程序。程序读取用户选择的文本文件,然后将其显示为 .html 对象。我正在使用“扫描”功能来读取文本文件(NB 目前只尝试输出第一行)。程序运行,但输出未更新。为什么没有更新输出?谢谢。
library(shiny)
shinyApp(
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("text_file", "Choose text file",
multiple = FALSE,
accept = c(".txt")
)
),
mainPanel(htmlOutput("example"))
)
),
server <- function(input, output, session){
text <- reactive({
req(input$text_file)
x <- scan(input$text_file, what = "string", sep = "\n")[1]
})
# text output
output$example <- reactive({
renderUI({
HTML(x)
})
})
}
)
shinyApp(ui, server)
【问题讨论】:
标签: r shiny shiny-reactivity