Table of Contents
How to install R and RStudio
For semester 115-1: make sure that you have the latest version of R and RStudio installed on your computers:
- R - version 4.6.1 or newer
- RStudio - version RStudio-2026.08.1-195 or newer
Note that first, you need to install (or update) R on your computer (where all commands are processed), and then install RStudio (an editor that wraps around R). RStudio without R does not work, and installing or updating only RStudio without installing R is insufficient.
How to install R
- Download the installation file of the newest R version from CRAN1). Choose your operation system (e.g.
Donwload R for Windows), and then choose eitherInstall R for the first timeif you haven't install R before you your computer, orbaseif you already did and you are installing a new version; download the installation file and proceed further). If you are using Mac, you may need to Google some help (eg see this website for help). - Install the R program - you may keep the default location of installation files in Program Files/R. On Windows, the R folder in your Program Files folder may contain several subfolders with different R versions installed in parallel, e.g. R-2.10.1, R-2.11.1 etc.
- When you run the R program, you may change some basic setting (e.g. the size of the font, colour of the background (if you feel it is more comfortable to have it e.g. orange) in menu Edit > GUI preferences. If you change anything in this window, you need to click on Save button and save the file Rconsole to the folder /Program Files/R/R-version/etc.
How to update R
If you have R already installed on your computer and you want to update to newer version, the easiest way is simply to install the new version along the old one (and later possibly delete the old one if you don't need it or you want to save space on hard drive). All R versions are, if not changed, installed beside each other in R subfolder of Program Files folder (in the case of Windows). You may need to install also all the packages you used in the previous version. You can simply copy the folder library from the old R version to new R version and run an update procedure in new R version using the command update.packages. For this, do the following:
- Close all running R programs (or RStudio) before starting!
- Open some file manager (like Total Commander or Windows Explorer) and locate the
libraryfolder with R libraries from the previous version. This is usually located in c:\Program Files\R\R-x.x.x\library, where R-x.x.x is the number of the previous R version, e.g. R-3.1.2. In some cases it could, however, be somewhere else; if not sure, open R, and type.libPaths ()to see location of library path on your computer. - Copy all subfolders in
libraryfolder intolibraryfolder of the new version. Do not overwrite the newer versions of files in thelibraryfolder of the new R version. - Open the new R version, and update all packages using command
update.packages(ask = F)2). This should update all the packages to their latest version compatible with current version of R.
How to install RStudio
Download the latest version from RStudio website; you will need the Desktop version, Open Source Edition for your system; you may click here to get directly to the selection of the actual RStudio version. Follow the instructions for installation. If you already have RStudio installed on your computer, please check whether you have the latest version and update if you don't (in the RStudio menu, go to Help > Check for Updates).
RStudio is software that combines the R programming language with a text editor and a graphical user interface (and offers much more, such as organizing scripts and outputs into projects within a single folder and, for advanced users, convenient package building, document markup, etc.). One thing that's a bit not handy is RStudio's native graphical output - it offers its own sizeable graphical output in one of the subpanels (usually the bottom-right one), but it sometimes causes trouble (especially when you draw more complex figures). The workaround is to open the original R drawing panel - just type windows () (on Windows OS), quartz () (on macOS) or x11 () (on Linux/Unix) into the console, and a new active window will open (you can move it around the screen, or right-click on it with the mouse and select “Stay on top” to keep it as the top window always visible on your screen).
Optionally, there are a number of other text editors, which can be associated with R, e.g., Tinn-R. You are free to use the editor of your choice. In the class, we will use RStudio.
ask = F in the function update.packages makes sure that the update function will not ask you to prompt updating each package separately.