使用RStudio更新R

Update R using RStudio

我正在将RStudio与R版本2.15.0一起使用,并想更新到最新的R版本。

如何使用RStudio实现?


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

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

因此,为了安装R,

  • 转到http://www.r-project.org,
  • 点击" CRAN",
  • 然后选择您喜欢的CRAN网站。我喜欢堪萨斯州:http://rweb.quant.ku.edu/cran/。
  • 点击"为R下载XXX" [其中XXX是您的操作系统]
  • 请按照您操作系统的安装过程进行操作
  • 重新启动RStudio
  • --wait-我心爱的包裹呢?-

    好的,我使用Mac,所以我只能提供Mac的准确详细信息-也许其他人可以提供Windows / Linux的准确路径;我相信过程将是相同的。

    为了确保您的软件包可以与新版R一起使用,您需要:

  • 将软件包从旧的R安装版本移至新版本;在Mac OSX上,这意味着从此处移动所有文件夹:

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

    到这里:

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

    [在您要升级的任何版本中,都将用" 2.15"和" 3.0"替换。并且仅复制目标目录中尚未存在的任何软件包。也就是说,不要用旧的覆盖新的"基本"软件包-如果您这样做了,请放心,我们将在下一步中对其进行修复。如果这些路径对您不起作用,请尝试使用installed.packages()
    找到正确的路径名。]

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

    1
    2
    3
    4
    5
    6
    > 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---
  • 最后,为确保已完成所有操作,请在RStudio控制台中键入以下两个命令以查看所获得的内容:

    1
    2
    > version
    > packageStatus()

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

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

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

    查看@micstr的答案以获取更详细的演练。


    如果使用的是Windows,则可以使用安装程序。
    这里的用法示例


    我建议使用Windows软件包安装程序来完成此操作。该软件包不仅会更新您的R版本,还将复制和更新您的所有软件包。这里有一个关于这个主题的博客。只需在R Studio中运行以下命令并按照提示进行操作即可:

    1
    2
    3
    4
    5
    6
    # 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上具有功能

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

    To update your R version from within Rstudio using updateR you just have to run these five lines of code:

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

    at the end of installation process a message is going to confirm you the happy end:

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


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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    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.


    有一个名为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,然后:

    1
    2
    3
    4
    5
    6
    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中运行以下代码:

    1
    2
    3
    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,请参阅此处的说明。