RShiny 응용 프로그램의 일부가 Windows 서비스의 지연된 시작과 같이 지연된 방식으로 실행될 수 있습니까?반짝 이는 응용 프로그램에서 지연된 실행
자세히 설명해 드리겠습니다.
탭이있는 반짝이는 앱이 있습니다. 각 탭에는 사이드 바 패널에 일련의 라디오 버튼이 있습니다. 각 라디오 버튼을 클릭하면 보고서가 나타납니다. 내 설정은 이것만큼 간단합니다.
그러나 앱을로드 할 때마다 첫 번째 탭이 자동으로 렌더링되면이 탭 아래의 모든 라디오 버튼과 관련된 모든 보고서가 실행 된 다음 첫 번째 라디오 버튼이 선택되고 상호 관련 보고서가 표시됩니다. 이 모든 과정은 약 10 ~ 11 초 정도 걸립니다.
서버를 시작하는 동안 global.R에서 myData.RData 파일을 읽습니다. 그래서 모든 데이터는 서버가 시작될 때 미리 가져온 것입니다. 탭에 초점을 맞추면 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