如何在ubuntu中升级R ?

时间:2022-07-03 21:22:52

I have R 2.12.1 installed in my ubuntu, and I'd like upgrade to lastest version 2.15, how can achieve that ? Thanks

我的ubuntu安装了r2.12.1,我想升级到最新的2.15版本,怎么实现呢?谢谢

1 个解决方案

#1


216  

Since R is already installed, you should be able to upgrade it with this method. First of all, you may want to have the packages you installed in the previous version in the new one,so it is convenient to check this post. Then, follow the instructions from here

由于R已经安装,您应该能够使用此方法升级它。首先,您可能想要在新版本中安装上以前版本中的包,所以检查这篇文章很方便。然后,按照这里的说明

  1. Open the sources.list file:

    打开来源。文件列表:

    sudo nano /etc/apt/sources.list    
    
  2. Add a line with the source from where the packages will be retrieved. For example:

    添加一行与源代码一起的代码,包将从其中检索。例如:

    deb https://cloud.r-project.org/bin/linux/ubuntu/ version/
    

    Replace https://cloud.r-project.org with whatever mirror you would like to use, and replace version/ with whatever version of Ubuntu you are using (eg, trusty/, xenial/, and so on). If you're getting a "Malformed line error", check to see if you have a space between /ubuntu/ and version/.

    用你想要使用的镜像替换https://cloud.r-project.org,用你正在使用的Ubuntu的任何版本替换版本/(例如,可信/,xenial/,等等)。如果你有一个“畸形线错误”,检查你是否有一个间隔/ubuntu/和版本/。

  3. Fetch the secure APT key:

    获取安全的APT密钥:

    gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
    

    or

    gpg --hkp://keyserver keyserver.ubuntu.com:80 --recv-key E084DAB9
    
  4. Add it to keyring:

    将其添加到keyring:

    gpg -a --export E084DAB9 | sudo apt-key add -
    
  5. Update your sources and upgrade your installation:

    更新你的资源和升级你的安装:

    sudo apt-get update && sudo apt-get upgrade
    
  6. Install the new version

    安装新版本

    sudo apt-get install r-base-dev
    
  7. Recover your old packages following the solution that best suits to you (see this). For instance, to recover all the packages (not only those from CRAN) the idea is:

    按照最适合您的解决方案恢复旧的包(请参见此)。例如,要恢复所有的包(不仅仅是从CRAN恢复的包),其想法是:

    -- copy the packages from R-oldversion/library to R-newversion/library, (do not overwrite a package if it already exists in the new version!).

    -将包从R-oldversion/library复制到R-newversion/library(如果包已经存在于新版本中,不要覆盖它!)

    -- Run the R command update.packages(checkBuilt=TRUE, ask=FALSE).

    ——运行R命令更新。包(checkBuilt = TRUE,问= FALSE)。

#1


216  

Since R is already installed, you should be able to upgrade it with this method. First of all, you may want to have the packages you installed in the previous version in the new one,so it is convenient to check this post. Then, follow the instructions from here

由于R已经安装,您应该能够使用此方法升级它。首先,您可能想要在新版本中安装上以前版本中的包,所以检查这篇文章很方便。然后,按照这里的说明

  1. Open the sources.list file:

    打开来源。文件列表:

    sudo nano /etc/apt/sources.list    
    
  2. Add a line with the source from where the packages will be retrieved. For example:

    添加一行与源代码一起的代码,包将从其中检索。例如:

    deb https://cloud.r-project.org/bin/linux/ubuntu/ version/
    

    Replace https://cloud.r-project.org with whatever mirror you would like to use, and replace version/ with whatever version of Ubuntu you are using (eg, trusty/, xenial/, and so on). If you're getting a "Malformed line error", check to see if you have a space between /ubuntu/ and version/.

    用你想要使用的镜像替换https://cloud.r-project.org,用你正在使用的Ubuntu的任何版本替换版本/(例如,可信/,xenial/,等等)。如果你有一个“畸形线错误”,检查你是否有一个间隔/ubuntu/和版本/。

  3. Fetch the secure APT key:

    获取安全的APT密钥:

    gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
    

    or

    gpg --hkp://keyserver keyserver.ubuntu.com:80 --recv-key E084DAB9
    
  4. Add it to keyring:

    将其添加到keyring:

    gpg -a --export E084DAB9 | sudo apt-key add -
    
  5. Update your sources and upgrade your installation:

    更新你的资源和升级你的安装:

    sudo apt-get update && sudo apt-get upgrade
    
  6. Install the new version

    安装新版本

    sudo apt-get install r-base-dev
    
  7. Recover your old packages following the solution that best suits to you (see this). For instance, to recover all the packages (not only those from CRAN) the idea is:

    按照最适合您的解决方案恢复旧的包(请参见此)。例如,要恢复所有的包(不仅仅是从CRAN恢复的包),其想法是:

    -- copy the packages from R-oldversion/library to R-newversion/library, (do not overwrite a package if it already exists in the new version!).

    -将包从R-oldversion/library复制到R-newversion/library(如果包已经存在于新版本中,不要覆盖它!)

    -- Run the R command update.packages(checkBuilt=TRUE, ask=FALSE).

    ——运行R命令更新。包(checkBuilt = TRUE,问= FALSE)。