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
Machine Learning with R Cookbook, Second Edition

You're reading from   Machine Learning with R Cookbook, Second Edition Analyze data and build predictive models

Arrow left icon
Product type Paperback
Published in Oct 2017
Publisher Packt
ISBN-13 9781787284395
Length 572 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Ashish Bhatia Ashish Bhatia
Author Profile Icon Ashish Bhatia
Ashish Bhatia
Yu-Wei, Chiu (David Chiu) Yu-Wei, Chiu (David Chiu)
Author Profile Icon Yu-Wei, Chiu (David Chiu)
Yu-Wei, Chiu (David Chiu)
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Practical Machine Learning with R FREE CHAPTER 2. Data Exploration with Air Quality Datasets 3. Analyzing Time Series Data 4. R and Statistics 5. Understanding Regression Analysis 6. Survival Analysis 7. Classification 1 - Tree, Lazy, and Probabilistic 8. Classification 2 - Neural Network and SVM 9. Model Evaluation 10. Ensemble Learning 11. Clustering 12. Association Analysis and Sequence Mining 13. Dimension Reduction 14. Big Data Analysis (R and Hadoop)

Downloading and installing R

To use R, you must first install it on your computer. This recipe gives detailed instructions on how to download and install R.

Getting ready

If you are new to the R language, you can find a detailed introduction, language history, and functionality on the official website (http://www.r-project.org/). When you are ready to download and install R, please access the following link: http://cran.r-project.org/.

How to do it...

Please perform the following steps to download and install R for Windows and macOS:

  1. Go to the R CRAN website, http://www.r-project.org/, and click on the download R link, that is, http://cran.r-project.org/mirrors.html):
R Project home page
  1. You may select the mirror location closest to you:
CRAN mirrors
  1. Select the correct download link based on your operating system:
Click on the download link based on your OS

As the installation of R differs for Windows and macOS, the steps required to install R for each OS are provided here.

For Windows:

  1. Click on Download R for Windows, as shown in the following screenshot, and then click on base:
  1. Click on Download R 3.x.x for Windows:
  1. The installation file should be downloaded. Once the download is finished, you can double-click on the installation file and begin installing R, It will ask for you selecting setup language:
Installation step - Selecting Language
  1. The next screen will be an installation screen; click on Next on all screens to complete the installation. Once installed, you can see the shortcut icon on the desktop:
R icon for 32 bit and 64 bit on desktop
  1. Double-click on the icon and it will open the R Console:
The Windows R Console

For macOS X:

  1. Go to Download R for (Mac) OS X, as shown in the following screenshot.
  2. Click on the latest version (R-3.4.1.pkg file extension) according to your macOS version:
  1. Double-click on the downloaded installation file (.pkg extension) and begin to install R. Leave all the installation options as the default settings if you do not want to make any changes:
  1. Follow the onscreen instructions through Introduction, Read Me, License, Destination Select, Installation Type, Installation, and Summary, and click on Continue to complete the installation.
  1. After the file is installed, you can use spotlight search or go to the Applications folder to find R:
Use spotlight search to find R
  1. Click on R to open R Console:

As an alternative to downloading a Mac .pkg file to install R, Mac users can also install R using Homebrew:

  1. Download XQuartz-2.X.X.dmg from https://xquartz.macosforge.org/landing/.
  2. Double-click on the .dmg file to mount it.
  3. Update brew with the following command line:
        $ brew update  
  1. Clone the repository and symlink all its formulae to homebrew/science:
        $ brew tap homebrew/science  
  1. Install gfortran:
        $ brew install gfortran  
  1. Install R:
        $ brew install R      

For Linux users, there are precompiled binaries for Debian, RedHat, SUSE, and Ubuntu. Alternatively, you can install R from a source code. Besides downloading precompiled binaries, you can install R for Linux through a package manager. Here are the installation steps for CentOS and Ubuntu.

Downloading and installing R on Ubuntu:

  1. Add the entry to the /etc/apt/sources.list file replace <> with appropriate value:
        $ sudo sh -c "echo 'deb http:// <cran mirros site 
url>/bin/linux/ubuntu <ubuntu version>/' >> /etc/apt/sources.list"
  1. Then, update the repository:
        $ sudo apt-get update  
  1. Install R with the following command:
        $ sudo apt-get install r-base  
  1. Start R in the command line:
        $ R  

Downloading and installing R on CentOS 5:

  1. Get the rpm CentOS 5 RHEL EPEL repository of CentOS 5:
        $ wget
http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-
4.noarch.rpm
  1. Install the CentOS 5 RHEL EPEL repository:
        $ sudo rpm -Uvh epel-release-5-4.noarch.rpm  
  1. Update the installed packages:
        $ sudo yum update  
  1. Install R through the repository:
        $ sudo yum install R  
  1. Start R in the command line:
        $ R  

Downloading and installing R on CentOS 6:

  1. Get the rpm CentOS 5 RHEL EPEL repository of CentOS 6:
        $ wget
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-
8.noarch.rpm
  1. Install the CentOS 5 RHEL EPEL repository:
        $ sudo rpm -Uvh epel-release-6-8.noarch.rpm  
  1. Update the installed packages:
        $ sudo yum update  
  1. Install R through the repository:
        $ sudo yum install R  
  1. Start R in the command line:
        $ R  

Downloading and installing R on Fedora [Latest Version]:

$ dnf install R  

This will install R and all its dependencies.

How it works...

CRAN provides precompiled binaries for Linux, macOS X, and Windows. For macOS and Windows users, the installation procedures are straightforward. You can generally follow onscreen instructions to complete the installation. For Linux users, you can use the package manager provided for each platform to install R or build R from the source code.

See also

You have been reading a chapter from
Machine Learning with R Cookbook, Second Edition - Second Edition
Published in: Oct 2017
Publisher: Packt
ISBN-13: 9781787284395
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