Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Modern R Programming Cookbook

You're reading from   Modern R Programming Cookbook Recipes to simplify your statistical applications

Arrow left icon
Product type Paperback
Published in Oct 2017
Publisher Packt
ISBN-13 9781787129054
Length 236 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Jaynal Abedin Jaynal Abedin
Author Profile Icon Jaynal Abedin
Jaynal Abedin
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Installing and Configuring R and its Libraries 2. Data Structures in R FREE CHAPTER 3. Writing Customized Functions 4. Conditional and Iterative Operations 5. R Objects and Classes 6. Querying, Filtering, and Summarizing 7. R for Text Processing 8. R and Databases 9. Parallel Processing in R

Installing and configuring base R in Windows

In this recipe, you will learn to install R in the Windows platform and we will address other necessary configuration issues that are related to the Windows operating system.

Getting ready

To start this recipe, you will need to know your version of the Windows operating system, for example, whether it is Windows 7, 8, or 10. Also, you need to know specific architecture, such as 32-bit or 64-bit. Once you know the particulars of the operating system, you are ready to install base R by following the steps in the next section. Another thing that you need to check is whether R is already installed on your computer or not. You can easily check by inspecting the Start menu or task bar or desktop icon. Now, let's assume that you did not install R previously in your computer and this is the first time you are going to do so.

Once you get detailed information about your operating system, you will need to download the executable file for the Windows operating system. To find the latest version of R, you can visit the Comprehensive R Archive Network (CRAN) at http://cran.r-project.org/. On this web page, you will get to know the latest release of R and other related information.

To download the latest release of R for Windows, perform the following steps:

  1. Visit https://cran.r-project.org/bin/windows/, which will show you the following screen:
  1. On this web page, you will see base under the Subdirectories category. As a first-time user of R, you need to download the executable file from this link.
  2. Once you click on base, you will end up on this page, https://cran.r-project.org/bin/windows/base/ as shown in the following screenshot:
  1. Now, click on Download R 3.x.x (This version number might differ because during preparation of this recipe, the version was 3.3.3) for Windows. The executable file will be downloaded into your local storage.

How to do it...

Once you have downloaded the executable file, you are ready to install it on your computer. Perform the following steps and choose the options accordingly. The screenshots are for your convenience only:

  1. Go to the folder where you have stored the executable file that you have downloaded, by following the instructions in the previous section.
You must have administrator privileges to install the software.
  1. If you have administrator privileges, then just double-click on the executable file, or right-click on the mouse and select Run as administrator:
  1. In Windows 7, it will show a notification with the title User Access Control. In this case, you must choose Yes to proceed.
  2. The first thing it will ask you to do is choose a language, as shown in the following screenshot. Once you select your chosen language, click on the OK button. The R Setup Wizard will appear, and you will see various options to select in different pages:
  1. Click on Next > on this page to proceed with the installation:
  1. On this page, the GNU GENERAL PUBLIC LICENSE information will be displayed, and you will be asked to read and understand the licensing agreement and then click on the Next > button:
  1. Now, you will be asked to choose the destination folder where you want to store the installation files. Usually, by default, it shows C:/Program Files/, and sometimes, it also shows one more level C:/Program Files/R/R-x.x.x. You can keep the default location, or you can choose a separate destination based on your choice. Once you have selected the destination, click on the Next > button:
  1. At this stage, you will get the option to select the component that you want to install. You can choose either 32-bit Files only, 64-bit Files only, or both along with core files and message translation. After selecting the components, again click on the Next > button:
  1. Now, you will be asked whether you want to customize your startup or accept the defaults. The recommended option at this stage is to accept the defaults and click on the Next > button:
  1. You can decide whether you want to create the start menu folder or not and you can specify its name at this stage of installation:
  1. Finally, you will be given the option to choose whether you want to create a desktop icon and also create a quick launch icon. You can specify whether you want to save the version number into the computer's registry or not, and the last option is to associate file name extensions .R and .RData with the software. Once you are done with selecting the options, click on Next > and the installation will be started:

How it works...

Once you follow the steps described in the How to do it… section, the R software will be installed, and it's ready to use. You can open R using either the desktop icon or quick launch icon, or from the Start menu.

However, to do some advanced-level work in R or if you want to open the R console from the Windows Command Prompt, you need to do some configuration that is specific to the operating system. In this subsection, you will see how the configuration works.

If you want to access the R terminal from the Windows Command Prompt, then you must open the Windows Command Prompt, and then type R and press Enter. However, without correctly configuring R, you won't be able to open the R terminal in this way. The following are the steps to configure R:

  1. Right-click on the Computer icon and select Properties from the following screen:
  1. Now, click on Advanced system settings. It will open up the System Properties window as shown in the following screenshot:
  1. At the bottom of the System Properties window, you will see Environment Variables…. Click on it and it will show the following screen:
  1. The Environment Variables window will pop up in which you will see two separate sections, one for User variables and another for System variables.
  2. In the System variables section, select the Path variable and then click on Edit…:
  1. Now, in this Path variable, add the location where you have installed R software. Choose the location where the R.exe and R.dll file belongs, for example, C:\Program Files\R\R-3.3.2\bin\x64.
  2. Put the location at the end of the Path variable after putting in a semicolon (;) and then click on OK on each of the window opened.

Once you have performed the preceding steps, it is the time to check whether you have correctly configured environment variables by performing the following steps:

  1. Go to the Start menu.
  2. Type cmd in the search box.
  3. Then, click on cmd.exe. It will open a black screen called Windows Command Prompt:
  1. Type R and hit Enter. If the R console opens, then everything is alright and you have correctly configured R in Windows:

There's more...

If you want to customize the R console, its display font, font size, and others, you can edit the preferences from the menu. For example, navigate to Edit | GUI preference…. You will see the following screen. You are now able to change anything you want to customize your R console and other things:

See also

In this recipe, you have gone through the steps based on the Windows operating system. If you want to install and configure R for Linux, see the next recipe Installing and configuring base R in Linux.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image