When it comes to software applications, it is always handy to have more than one way to go about installing them. For R on Windows, there are several ways to accomplish this. In this post, I will be sharing a few that I have encountered and actually used.
1. From CRAN Homepage
The commonest approach to installing R is to visit the Comprehensive R Archive Network (CRAN) homepage at https://cran.r-project.org. On that page, one will see links referring to installation pages for different operating systems. Our interest in this is post is on Windows.
When we click on the link for Windows, we are taken to the R for Windows homepage:
Click on “install R for the first time” and you will be taken to the installation page for the current version of R (version 4.2.2 at the time of writing).
Click on “Download R-x.x.x for Windows…” and the installer will be downloaded to your machine. Save it at a destination of your choice (usually the ‘Downloads’ folder) and then run the file to start the installation proper. This will launch the installation wizard and you can safely use the default options to complete the process as indicated in the next few images:
When setup is complete, R can be launched from the Start Menu
2. From R with the installr package
If R is already installed, then it is easier to install updates with the installr package (this works best with R GUI). This is very useful since R Core is guaranteed to release key updates at least 2-3 times every year. This is the code to use
# install.packages("installr") # => run only if package is not already installed installr::updateR()
If there’s a more recent version of R available, the following dialog will appear:
This is followed by an offer to see what’s new in R; this can be safely ignored:
Then you’ll be asked if you actually want to install the new R version. Selecting ‘No’ will terminate setup.
Once accepted, a progress bar appears for downloading the installer from CRAN:
This is followed by the wizard prompts as seen in the first section. However, this can be turned off in the function by setting the appropriate arguments. I won’t go into that in this post, but interested readers should look at the help file with
?installr::updateR. (I do have a utility package I created for personal use that has a function,
easy_updateR, to do this without the bells and whistles)
After the installation, there will be additional housekeeping prompts. If there’s been a major/minor version change (following the scheme
MAJOR.MINOR.PATCH), there may be a need to accept the invitation to update your other packages, but this can always be done later.
3. From the Command Line
By “command line” we are referring to Windows Terminal, PowerShell, or Command Prompt.
Windows now has a package management tool, winget, that eases the installation of software via the command line. Recent builds of Windows 10 and now Windows 11, come with it pre-installed, but if you’re using an older version, it has to be installed from the Microsoft Store. To check whether you have it, simply run
winget at the prompt, and you will see a help message:
To install R, open the command line as an administrator (I’m using PowerShell) and run the tool as follows:
winget install Rproject.R
Follow any prompts, accept the defaults, and R will be installed–this time you won’t have to resort to the wizard. The great thing about this method is that it can be fully automated and it’s the most efficient!
There you have it, 3 easy ways to install R on Windows! Do you know of any other ways to do this? If your answer is ‘yes!’, feel free to tell us in the comments.