The easiest way to update R is to simply download the newest version. Install that, and it will overwrite your current version. There are also packages to do the updating: updateR for Mac, and installr for Windows.
For command line use you can update R by running: require(installr) updateR() # this will open dialog boxes to take you through the steps. Or install a new software simply by running: require(installr) installr() # user can easily select (via a GUI interface) a software to install.
Updating RStudio is easy, just go to Help > Check for Updates to install newer version.
To update multiple packages, or indeed all packages, RStudio provides helpful tools. Click Tools - Check for Package Updates . A dialogue box will appear and you can select the packages you wish to update.
For completeness, the answer is: you can't do that from within RStudio. @agstudy has it right - you need to install the newer version of R, then restart RStudio and it will automagically use the new version, as @Brandon noted.
It would be great if there was an update.R() function, analogous to the install.packages() function or the update.packages(function).
ok, I use a Mac, so I can only provide accurate details for the Mac - perhaps someone else can provide the accurate paths for windows/linux; I believe the process will be the same.
To ensure that your packages work with your shiny new version of R, you need to:
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()
You install a new version of R from the official website.
RStudio should automatically start with the new version when you relaunch it.
In case you need to do it manually, in RStudio, go to :Tools -> options -> General.
Check @micstr's answer for a more detailed walkthrough.
If you are using windows, you can use installr. Example usage here
I would recommend using the Windows package installr to accomplish this. Not only will the package update your R version, but it will also copy and update all of your packages. There is a blog on the subject here. Simply run the following commands in R Studio and follow the prompts:
# 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.
If you're using a Mac computer, you can use the new updateR package to update the R version from RStudio: http://www.andreacirillo.com/2018/02/10/updater-package-update-r-version-with-a-function-on-mac-osx/
In summary, you need to perform this:
To update your R version from within Rstudio using updateR you just have to run these five lines of code:
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:
everything went smoothly open a Terminal session and run 'R' to assert that latest version was installed
Paste this into the console and run the commands:
## 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.
There's a new package called installr that can update your R version within R on the Windows platform. The package was built under version 3.2.3
From R Studio, click on Tools and select Install Packages... then type the name "installr" and click install. Alternatively, you may type install.packages("installr") in the Console.
Once R studio is done installing the package, load it by typing require(installr) in the Console.
To start the updating process for your R installation, type updateR(). This function will check for newer versions of R and if available, it will guide you through the decisions you need to make. If your R installation is up-to-date, it will return FALSE.
If you choose to download and install a newer version. There's an option for copying/moving all of your packages from the current R installation to the newer R installation which is very handy.
Quit and restart R Studio once the update process is over. R Studio will load the newer R version.
Follow this link if you wish to learn more on how to use the installr package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With