2024-03-16 05:00:05

使用RStudio更新R

如何通过RStudio更新R ?


当前回答

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

其他回答

不要用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 ->>目前安装程序在Linux/MacOS上不可用(请参阅当前版本0.20的文档)。随着R的安装,你可以按照这些说明(在Ubuntu中,尽管在其他发行版中想法是相同的:添加源代码,更新和升级,然后安装)。

您可以从官方网站上安装一个新版本的R。

当您重新启动RStudio时,它将自动以新版本启动。

如果您需要手动执行,在RStudio中,请转到:工具->选项->通用。

查看@micstr的答案,了解更详细的攻略。

如果您使用的是windows,则可以使用安装程序。 示例用法

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

## 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中,单击Tools并选择Install Packages…然后输入名称“installr”并单击install。或者,你也可以在控制台中输入install.packages("installr")。

一旦R studio完成了包的安装,在控制台中输入require(installr)来加载它。

要启动R安装的更新过程,输入updateR()。这个函数将检查R的新版本,如果可用,它将指导您做出需要做出的决定。如果您的R安装是最新的,它将返回FALSE。

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

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

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