我该如何通过RStudio更新R?
好的,我使用Mac电脑,因此我只能提供Mac电脑的准确细节 - 也许其他人可以提供Windows / Linux的准确路径; 我相信过程是相同的。
为了确保您的软件包与最新版本的R兼容,请执行以下操作:
move the packages from the old R installation into the new version; on Mac OSX, this means moving all folders from here:
/Library/Frameworks/R.framework/Versions/2.15/Resources/library
to here:
/Library/Frameworks/R.framework/Versions/3.0/Resources/library
[where you'll replace "2.15" and "3.0" with whatever versions you're upgrading from and to. And only copy whatever packages aren't already in the destination directory. i.e. don't overwrite your new 'base' package with your old one - if you did, don't worry, we'll fix it in the next step anyway. If those paths don't work for you, try using installed.packages()
to find the proper pathnames.]
now you can update your packages by typing update.packages()
in your RStudio console, and answering 'y' to all of the prompts.
> 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---
finally, to reassure yourself that you have done everything, type these two commands in the RStudio console to see what you have got:
> version
> packageStatus()
system
调用来完成一些事情了... - DasonupdateR()
后需要多长时间?我的 Rstudio 会在运行此命令时卡住。不确定这是否正常。谢谢! - Ryan Chase我建议使用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-with-a-function-on-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
install.packages(as.vector(needed_packages)) Error in install.packages : object 'needed_packages' not found
。 - petziUpdateR
工作正常,但没有对我的软件包进行任何更改。我使用的是 R.app
控制台,而不是 Rstudio。 - DryLabRebel## 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.
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()
苹果电脑操作系统 ->> 您可以使用updateR软件包。该软件包不在CRAN上,因此您需要在Rgui中运行以下代码:
install.packages("devtools")
devtools::install_github("AndreaCirilloAC/updateR")
updateR(admin_password = "PASSWORD") # Where "PASSWORD" stands for your system password
installr
不可用于Linux/MacOS(请参阅当前版本0.20的文档)。由于已安装了R,因此您可以按照这些说明进行操作(在Ubuntu中,尽管其他发行版的思路相同:添加源��更新和升级并安装)。在安装完新版本的R之后,只需重新启动R Studio即可。要确认您正在使用新版本,请在控制台中输入 >version ,您应该会看到新的细节。