首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与旧版本的Rstudio一起使用rstudio::openProject

与旧版本的Rstudio一起使用rstudio::openProject
EN

Stack Overflow用户
提问于 2018-02-12 13:19:03
回答 1查看 289关注 0票数 1

我使用Rstudio Version 0.99.903和最新版本的库rstudioapi (rstudioapi_0.7)。

在尝试rstudioapi::openProject('MyProject')时,我得到:

错误:函数openProject在RStudio中找不到

下面是rstudioapi函数的代码:

代码语言:javascript
复制
rstudioapi::openProject
function (path = NULL, newSession = FALSE) 
{
    callFun("openProject", path, newSession)
}
<environment: namespace:rstudioapi>

问题很可能是我的Rstudio版本并不是最新的。

不幸的是,我无法下载更高版本的Rstudio (我在工作中只能使用授权软件),是否可以单独下载该功能并使其正常工作?

显然,在Rstudio中,打开项目的功能已经存在,所以我相信这可能是一个非常简单的修复,不需要更新整个软件。

我使用R version 3.3.1Rstudio Version 0.99.903

深入研究代码,我所要寻找的函数似乎是.rs.api.openProject

通过浏览我在https://github.com/rstudio/rstudio/blob/master/src/cpp/r/R/Api.R中找到的rstudio的源代码:

代码语言:javascript
复制
.rs.addApiFunction("openProject", function(path = NULL,
                                           newSession = FALSE)
{
  # default to current project directory (note that this can be
  # NULL if the user is not within an RStudio project)
  if (is.null(path))
    path <- .rs.getProjectDirectory()

  path <- .rs.ensureScalarCharacter(path)

  # attempt to initialize project if necessary
  rProjFile <- .rs.api.initializeProject(path)

  # request that we open this project
  invisible(
    .Call("rs_requestOpenProject",
          rProjFile,
          newSession,
          PACKAGE = "(embedding)")
  )
})

我执行完整的文件以更新所有函数(可能不是最安全的决定,而是作为第一次迭代)。

在此之后,我可以进一步使用我的rstudioapi::openProject('MyProject')代码,但是它仍然失败,因为我没有定义ensureScalarCharacterrs_requestOpenProject,也没有在github中找到这些代码。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-01 22:54:48

不幸的是,您试图用旧版本的RStudio所做的事情是不可能的。rs_requestOpenProject只是不存在于您的IDE版本中,而且由于它是本机代码,所以没有办法对它进行修补(对您的组织来说,这比更新IDE更好)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48747464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档