使用RStudio更新R.

Ada*_*NYC 264 r rstudio

我正在使用RS版本的R版本2.15.0,并希望更新到最新的R版本.

如何使用RStudio实现这一目标?

Rya*_*tic 270

为了完整起见,答案是:你不能在RStudio中做到这一点.@agstudy说得对 - 你需要安装较新版本的R,然后重新启动RStudio,它会自动使用新版本,正如@Brandon所说.

如果有一个update.R()函数会很好,类似于install.packages()函数或update.packages(函数).

所以,为了安装R,

  1. 转到http://www.r-project.org,
  2. 点击'CRAN',
  3. 然后选择您喜欢的CRAN站点.我喜欢堪萨斯州:http://rweb.quant.ku.edu/cran/.
  4. 点击"下载R for XXX"[其中XXX是您的操作系统]
  5. 按照操作系统的安装过程进行操作
  6. 重启RStudio

- 等 - 我心爱的包裹怎么样? -

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

为了确保您的软件包能够使用闪亮的新版R,您需要:

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

    /Library/Frameworks/R.framework/Versions/2.15/Resources/library
    
    Run Code Online (Sandbox Code Playgroud)

    到这里:

    /Library/Frameworks/R.framework/Versions/3.0/Resources/library
    
    Run Code Online (Sandbox Code Playgroud)

    [无论您升级到哪个版本,都将替换"2.15"和"3.0".并且只复制目标目录中尚未包含的任何包.也就是说,不要用你的旧包覆盖你的新'基础'包 - 如果你这样做了,不要担心,我们会在下一步修复它.如果这些路径不适合您,请尝试使用installed.packages() 以查找正确的路径名.]

  2. 现在,您可以通过键入update.packages()RStudio控制台来更新您的软件包,并回答所有提示的"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---
    
    Run Code Online (Sandbox Code Playgroud)
  3. 最后,为了让自己放心,你已经完成了所有工作,在RStudio控制台中键入这两个命令,看看你得到了什么:

    > version
    > packageStatus()
    
    Run Code Online (Sandbox Code Playgroud)

  • 这不是我自己的工作,但已经为Windows用户完成了这项工作:https://github.com/talgalili/installr (16认同)
  • 每当有人说你不能用R做某事它只会让我想要这样做.看起来是时候用RCurl和一些`系统`调用来破解一些东西...... (4认同)
  • 因此,后面的答案表明,"正确"答案和最高投票答案都没有给出一个非常完整的答案,似乎这里显而易见,应该做些什么来更新这个. (3认同)
  • 似乎终于有了一个R软件包,可以使用Mac计算机从RStudio更新R:https://github.com/AndreaCirilloAC/updateR (2认同)

ags*_*udy 129

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

重新启动时,RStudio应自动从新版本开始.

如果你需要手动完成,在RStudio中,请转到:工具 - >选项 - >常规.

查看@ micstr的答案以获得更详细的演练.

  • RStudio会自动检测到这种情况...如果要使用其他(先前的x32,x64)位版本,则只需更新该选项. (47认同)
  • @Brandon Bertelsen怎么样?它永远不会更新我的R版本.帮助菜单中的"更新"仅是RStudio的更新. (7认同)
  • 过时的答案.安装新版本的R后,必须重新启动RStudio.对于RStudio,要自动检测新版本,请关闭并重新打开RStudio. (2认同)

Jam*_*ers 111

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

  • 请注意,您可以从RStudio内部运行更新过程 (7认同)
  • 这也是我的选择模式.移动所有包的代码特别容易.`#install/loading the package:if(!require(installr)){install.packages("installr"); require(installr)} #load/install + load installr updateR(F,T,T,F,T,F,T)#install,move,update.package,quit R. (4认同)
  • @SoilSciGuy如果你得到"文件中的错误(con,"r")"try`setInternet2(TRUE)`[参见疑难解答部分](https://github.com/talgalili/installr/) (3认同)

Bor*_*lis 58

我会建议使用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.
Run Code Online (Sandbox Code Playgroud)

  • installr软件包似乎是一个很好的解决方案,但不幸的是只适用于Windows. (10认同)

jro*_*las 43

如果您使用的是Mac计算机,则可以使用新的updateR软件包从RStudio更新R版本:http://www.andreacirillo.com/2018/02/10/updater-package-update-r-version- 与-A-功能上-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')
Run Code Online (Sandbox Code Playgroud)

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

everything went smoothly
open a Terminal session and run 'R' to assert that latest version was installed
Run Code Online (Sandbox Code Playgroud)

  • 这似乎又成为一个问题了。尝试从 3.5.2 -> 3.6.2 更新,并收到相同的消息。 (2认同)

Car*_*and 11

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

## 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. 
Run Code Online (Sandbox Code Playgroud)


Wes*_*koi 8

有一个名为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版本.

如果您想了解有关如何使用installr软件包的更多信息,请点击此链接.