繁体   English   中英

使用 RStudio 更新 R

[英]Update R using RStudio

如何通过 RStudio 更新 R?

为完整起见,答案是:您不能在 RStudio 中执行此操作。 @agstudy 说得对 - 您需要安装较新版本的 R,然后重新启动 RStudio,它将自动使用新版本,正如@Brandon 指出的那样。

如果有一个 update.R() 函数就好了,类似于 install.packages() 函数或 update.packages(function)。

所以,为了安装 R,

  1. http://www.r-project.org
  2. 点击“克兰”,
  3. 然后选择您喜欢的 CRAN 站点。 我喜欢堪萨斯州: http : //rweb.quant.ku.edu/cran/
  4. 单击“为 XXX 下载 R”[其中 XXX 是您的操作系统]
  5. 遵循适用于您的操作系统的安装过程
  6. 重启 RStudio

--等等-我心爱的包裹呢??--

好吧,我用的是 Mac,所以我只能提供 Mac 的准确细节——也许其他人可以提供 windows/linux 的准确路径; 我相信这个过程会是一样的。

为确保您的软件包与闪亮的 R 新版本兼容,您需要:

  1. 将旧 R 安装中的包移动到新版本中; 在 Mac OSX 上,这意味着从这里移动所有文件夹:

     /Library/Frameworks/R.framework/Versions/2.15/Resources/library

    到这里:

     /Library/Frameworks/R.framework/Versions/3.0/Resources/library

    [您将用您要升级的任何版本替换“2.15”和“3.0”。 并且只复制目标目录中尚未存在的任何包。 即不要用旧的包覆盖新的“基础”包——如果你这样做了,别担心,我们会在下一步修复它。 如果这些路径不适合您,请尝试使用installed.packages()来查找正确的路径名。]

  2. 现在,您可以通过在 RStudio 控制台中键入update.packages()来更新您的软件包,并对所有提示回答“y”。

     > update.packages(checkBuilt=TRUE) class : Version 7.3-7 installed in /Library/Frameworks/R.framework/Versions/3.0/Resources/library Version 7.3-8 available at http://cran.rstudio.com Update (y/N/c)? y ---etc---
  3. 最后,为了让自己确信您已经完成了所有操作,请在 RStudio 控制台中键入以下两个命令以查看您得到了什么:

     > version > packageStatus()

您从官方网站安装了新版本的 R。

当您重新启动 RStudio 时,它应该会自动以新版本启动。

如果您需要手动执行此操作,请在 RStudio 中转到:工具 -> 选项 -> 常规。

检查@micstr 的答案以获得更详细的演练。

如果您使用的是 Windows,则可以使用installr 示例用法在这里

我会建议使用Windows包installr做到这一点。 该软件包不仅会更新您的 R 版本,还会复制和更新您的所有软件包。 有关于这一主题的博客在这里 只需在 R Studio 中运行以下命令并按照提示操作:

# installing/loading the package:
if(!require(installr)) {
install.packages("installr"); require(installr)} #load / install+load installr

# using the package:
updateR() # this will start the updating process of your R installation.  It will check for newer versions, and if one is available, will guide you through the decisions you'd need to make.

如果您使用的是Mac 计算机,则可以使用新的updateR包从 RStudio 更新 R 版本: http : //www.andreacirillo.com/2018/02/10/updater-package-update-r-version- mac-osx 上的功能/

总之,您需要执行以下操作:

要使用 updateR 从 Rstudio 中更新您的 R 版本,您只需运行以下五行代码

 install.packages('devtools') #assuming it is not already installed library(devtools) install_github('andreacirilloac/updateR') library(updateR) updateR(admin_password = 'Admin user password')

在安装过程结束时,一条消息将确认您的快乐结局:

 everything went smoothly open a Terminal session and run 'R' to assert that latest version was installed

将其粘贴到控制台并运行以下命令:

## How to update R in RStudio using installr package (for Windows)
## paste this into the console and run the commands
## "The updateR() command performs the following: finding the latest R version, downloading it, running the installer, deleting the installation file, copy and updating old packages to the new R installation."
## more info here: https://cran.r-project.org/web/packages/installr/index.html

install.packages("installr")
library(installr)
updateR()

## Watch for small pop up windows. There will be many questions and they don't always pop to the front. 
## Note: It warns that it might work better in Rgui but I did it in Rstudio and it worked just fine. 

有一个名为installr的新包,它可以在 Windows 平台上的 R 中更新您的 R 版本。 该软件包是在 3.2.3 版本下构建的

在 R Studio 中,单击“工具”并选择“安装软件包...”,然后键入名称“installr”并单击“安装”。 或者,您可以在控制台中键入install.packages("installr")

R studio 完成安装包后,通过在控制台中键入require(installr)来加载它。

要开始 R 安装的更新过程,请键入updateR() 此函数将检查 R 的更新版本,如果可用,它将指导您完成需要做出的决定。 如果您的 R 安装是最新的,它将返回 FALSE。

如果您选择下载并安装较新的版本。 有一个选项可以将所有包从当前的 R 安装复制/移动到较新的 R 安装,这非常方便。

更新过程结束后退出并重新启动 R Studio。 R Studio 将加载较新的 R 版本。

如果您希望了解有关如何使用安装程序包的更多信息,请点击此链接

安装新版本的 R 后,只需重新启动 R Studio。要确认您使用的是新版本,>version,您应该会看到新的详细信息。

不要使用 Rstudio 来更新 R。Rstudio 不是 R,Rstudio 只是一个 IDE。 此答案是针对不同操作系统的先前答案的总结。 对于所有操作系统,提前查看您已在此处安装的软件包会发生什么是很方便的。

WINDOWS ->> 以管理员身份打开 CMD/Powershell 并输入“R”进入交互模式。 如果这不起作用,请搜索并运行 RGui.exe 而不是在控制台中编写 R ...然后:

lib_path <- gsub( "/", "\\\\" , Sys.getenv("R_LIBS_USER"))
install.packages("installr", lib = lib_path)
install.packages("stringr", lib_path)
library(stringr, lib.loc = lib_path)
library(installr, lib.loc = lib_path)
installr::updateR()

MacOS ->> 您可以使用updateR包。 该软件包不在 CRAN 上,因此您需要在 Rgui 中运行以下代码:

install.packages("devtools")
devtools::install_github("AndreaCirilloAC/updateR")
updateR(admin_password = "PASSWORD") # Where "PASSWORD" stands for your system password

请注意, 计划在不久的将来合并updateR 和 installR 以同时适用于 Mac 和 Windows。

Linux ->> 目前安装程序installr用于 Linux/MacOS(请参阅当前版本 0.20 的文档)。 安装 R 后,您可以按照这些说明进行操作(在 Ubuntu 中,尽管在其他发行版中的想法是相同的:添加源、更新和升级并安装。)

我发现对我来说,在 Linux 下保持最新状态的最佳永久解决方案是安装 R-patched 项目。 这将使您的 R 安装保持最新,您甚至不需要在安装之间移动您的包(这在 RyanStochastic 的回答中有所描述)。

对于 openSUSE,请参阅此处说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM