2024-03-16 05:00:05

使用RStudio更新R

如何通过RStudio更新R ?


当前回答

如果你使用的是Mac电脑,你可以使用新的updateR包从RStudio更新R版本:http://www.andreacirillo.com/2018/02/10/updater-package-update-r-version-with-a-function-on-mac-osx/

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

要在Rstudio中使用updateR更新你的R版本,你只需要运行这五行代码: Install.packages ('devtools') #假设尚未安装 库(devtools) install_github (andreacirilloac /更新) 库(更新) updateR(admin_password = 'Admin用户密码') 在安装过程结束时,一条消息将确认你的幸福结局: 一切都很顺利 打开一个Terminal会话并运行'R'来断言已经安装了最新版本

其他回答

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

为了完整起见,答案是:您不能从RStudio内部完成该操作。@agstudy是正确的-你需要安装新的R版本,然后重新启动RStudio,它会自动神奇地使用新版本,正如@Brandon指出的那样。

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

为了安装R,

登录http://www.r-project.org, 点击“CRAN”, 然后选择你喜欢的CRAN网站。我喜欢堪萨斯州:http://rweb.quant.ku.edu/cran/。 点击“下载R for XXX”[其中XXX是你的操作系统] 遵循操作系统的安装过程 重启RStudio 喜乐

等等——那我心爱的包裹怎么办??--

好吧,我使用的是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()

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

## 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. 

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

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

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

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

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