【发布时间】:2018-11-01 11:56:14
【问题描述】:
我有一个闪亮的应用程序,它应该首先从两个 excel 文件中提取/读取数据,然后使用响应式自定义 excel 文件的结果以生成两个表。问题是excel文件很重,应用程序需要花费大量时间来读取excel文件。它还减慢了反应性响应时间。下面是一个解释我的应用程序结构的虚拟代码。
library(readxl)
ui <- fluidPage(
tableOutput('dt1'),
tableOutput('dt2'),
selectInput('choice','TLT Select',choices= c('Yes','No'))
)
server <- shinyServer(function(input, output){
t.1 a <-as.data.frame(read_excel(path ="A.xlsx") ,stringsAsFactors = FALSE) #this is a 45 MB excel file
t.2 <- a <-as.data.frame(read_excel(path ="B.xlsx") ,stringsAsFactors = FALSE) # this is a 50 MB excel file
excel.a <- reactive({
if (input$choice == 'Yes') {
subset(t.1, t.1$Action == 'Yes') }
else
{subset(t.1, t.1$Action == 'No')}
excel.b <- reactive({
if (input$choice == 'Yes') {
subset(t.2, t.2$Action == 'Yes') }
else
{subset(t.2, t.2$Action == 'No')}
output$dt1 <- renderTable({
excel.1()
})
output$dt2 <- renderTable({
excel.2()
})
})
}
shinyApp(ui, server)
这当然不是一个可重现的示例,但这就是我的查询的结构。知道如何让它更高效、更快,从而使其加载更快,反应也更快吗?
谢谢
【问题讨论】: