小编shi*_*gav的帖子

在R Shiny app中延迟执行

是否有可能让RShiny应用程序的某些部分以延迟的方式执行,就像Windows服务中的延迟启动一样?

让我详细说明一下.

我有一个带标签的闪亮应用程序.每个选项卡在sidebarPanel上都有一堆单选按钮.单击每个单选按钮会显示一个报告.我的设置就像这样简单.

但是,当我每次加载应用程序时以及第一个选项卡自动呈现时,将执行与此选项卡下所有单选按钮关联的所有报告,然后选择第一个单选按钮并显示其关联报告.整个过程大约需要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 …
Run Code Online (Sandbox Code Playgroud)

r shiny

9
推荐指数
1
解决办法
5666
查看次数

在R中使用聚合函数时,波形符和"by"之间的差异

每次我在data.frame上进行聚合时,我都默认使用"by = list(...)"参数.但我确实在stackoverflow和其他地方看到了解决方案,其中在"formula"参数中使用了tilde(〜).我有点看到"by"参数作为围绕这些变量的"枢轴".

在某些情况下,输出完全相同.例如:

aggregate(cbind(df$A, df$B, df$C), FUN = sum, by = list("x" = df$D, "y" = df$E))

AND

aggregate(cbind(df$A, df$B, df$C) ~ df$E, FUN = sum)
Run Code Online (Sandbox Code Playgroud)

两者之间有什么区别,你什么时候使用哪个?

aggregate r dataframe

3
推荐指数
1
解决办法
1010
查看次数

标签 统计

r ×2

aggregate ×1

dataframe ×1

shiny ×1