RShinyアプリの一部がWindowsサービスの遅延開始と同じように遅れて実行される可能性はありますか?Rシャイニーアプリでの実行の遅延
詳細を教えてください。
私はタブ付きの光沢のあるアプリを持っています。各タブには、サイドバーパネルに一連のラジオボタンがあります。各ラジオボタンをクリックするとレポートが表示されます。私のセットアップはこれほど簡単です。
ただし、毎回アプリを読み込んで最初のタブが自動レンダリングされると、このタブのすべてのラジオボタンに関連付けられたすべてのレポートが実行され、最初のラジオボタンが選択され、関連するレポートが表示されます。このプロセス全体は、10〜11秒かかります。
サーバーの起動時に、my.RDataファイルをglobal.Rで読み込むだけです。したがって、すべてのデータはサーバーの起動時にプリフェッチされます(そして、私はメモリに保持されていると仮定しています)。タブがフォーカスされると、myData.RDataのdata.framesが読み込まれ、一連のggplots(renderPlot)とテーブル(renderText)が呼び出されます。
最初のレポートを数秒でレンダリングしてから、他のggplotsとテーブルを実行する方法はありますか?私は反応性導体と分離を通って行ったが、私の問題にどのような解決策が当てはまるのか理解できなかった。
また、負荷(およびリフレッシュ)時間を短縮できる他の方法はありますか?
問題を理解するのに役立ついくつかのコード..
# In server.R
library(shiny)
library(plyr)
library(ggplot2)
library(grid)
source("a.R", local=TRUE)
source("b.R", local=TRUE)
shinyServer(function(input, output) {
# The below two lines represent a report pair to me. So I have a Bar plot and the associated Table report.
output$wSummaryPlot = renderPlot({ print(drawBarPlotA("Bar Plot A")) })
output$wSummaryTable = renderText({ tableA() })
# There are about 20 such pairs in server.R
# Please note that I am including other R file by "source". The first two lines shows that. Don't know if that is what is causing the problem.
# The drawBarPlotA and tableA are functions defined in one of the source files which are included above.
# There are 5 such files which are included similarly.
})
# In ui.R
shinyUI(pageWithSidebar(
headerPanel(windowTitle = "Perfios - DAS", addHeader()),
sidebarPanel(
conditionalPanel(condition = "input.reportTabs == 1 && input.reportType == 'reportTypeA'",
wellPanel(radioButtons("showRadio", strong("Attributes:"),
c("Analysis A" = "a",
"Analysis B" = "b",
"Analysis C" = "c",
"Analysis D" = "d",
"Analysis E" = "e",
"Analysis F" = "f"
)))
))
mainPanel(
tabPanel("A", value = "1",
conditionalPanel(condition = "input.reportType == 'reportTypeA'",
conditionalPanel(condition = "showRadio == 'X'",
plotOutput("wSummaryPlot"), h4("Summary:"), verbatimTextOutput("wSummaryTable"))
# Many such element here to accomodate for those 20 reports...
)))
))
# In drawBarPlotA
drawBarPlotA = function(mainText) {
ggplot(data, aes(variable, value, fill = some_fill)) +
geom_bar(stat = "identity", position = "dodge", color = "grey") +
ylab("Y Label") +
xlab(NULL) +
theme_bw() +
ggtitle(mainText) +
scale_fill_brewer(palette = "Set1") +
annotate("text", x = 1.2, y = 0, label = "Copyright...", size = 4) +
theme(axis.text.x = element_text(angle = 45, hjust = 1, size = "12", face = "bold"),
axis.text.y = element_text(size = "12"),
plot.title = element_text(size = "14", vjust = 3, face = "bold"))
}
tableA = function() {
# This is a data.frame which is returned
data
}
あなたは私達にあなたの 'server.R'、' ui.R'およびその他の必要なコードを表示することができますか? – MadScone
コードスニペットを追加しました。お役に立てれば。ありがとう。 – shingav