首页 > 解决方案 > 重新启动和清除工作区后的异常行为可能与 R 和 RStudio 更新有关

问题描述

我最近升级到 R 版本 4.0.2 和 RStudio 1.3.1056 并相信这可能是这个问题的根源。在复制了我的 Shiny 代码的一部分以创建一个最小的可重现示例 (mprex) 后,我收到一段不在 mprex 中的代码的错误。我清除了我的 RStudio 工作区并重新启动了我的计算机和 RStudio,但仍然出现相同的错误。

这是我的代码:

library(shiny)

# Define UI
ui <- (fluidPage
       (
         fileInput("sessionFileName", "Session File Name")
       )
)

# Define server logic
server <- (function(input, output, session)
{
  
  inputParameters <- reactive ({
    if (is.null(input$sessionFileName)) return
    inFile <- input$sessionFileName
    if (!is.null(inFile)) {
      inputData <- readRDS(file=inFile$name)
    }
    inputIDs      <- names(inputData) 
    inputvalues   <- unlist(inputData) 
    for (i in 1:length(inputData)) {
      print (paste(inputIDs[i],inputvalues[[i]],sep=' '))
      session$sendInputMessage(inputIDs[i],  list(value=inputvalues[[i]]) )
    }
  })
})
  
# Start the shiny app
shinyApp(ui = ui, server = server)

这是我尝试运行代码时遇到的错误:

Error in reqHistoricalData(tws, twsEquity(equity), yesterday4PM, backtestFrequency,  : 
  could not find function "reqHistoricalData"

很明显,该错误与我尝试运行的代码无关。我意识到我的代码可能还有其他错误。启动代码时出现错误。我的猜测是,在另一台机器上运行此代码的人不会得到相同的错误,但我还不知道这是否属实。

这是我启动 RStudio 会话时的启动横幅。

R version 4.0.2 (2020-06-22) -- "Taking Off Again"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin17.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Workspace loaded from ~/Library/MobileDocuments/com~apple~CloudDocs/r Dev/.RData]

对于启动横幅的最后一行“[Workspace loaded from ~...]”,我不明白是否有办法删除和/或重置正在加载的工作空间。也许这就是这个问题的解决方案。

我的环境中确实有许多包,包括此错误所指的 IBrokers。我一直在运行其他访问函数reqHistoricalData()的 Shiny 脚本。

这是 Shiny 和/或 R 中的错​​误吗?关于如何让这段代码运行的任何想法?

标签: rshiny

解决方案


推荐阅读