**Forthcoming**

R is a free, open-source, adaptable, extensible language with tremendous applications in the field of statistical computation and data science. It offers basic programming and has very strong built-in functions for statistical analysis. It is also a perfect fit for Big Data solutions and supports graphical techniques to visualise and present data effectively.

In this book, students will learn about R programming, from its fundamentals to advanced concepts relating to data science and machine learning.

**Salient Features**

- Covers traditional programming concepts in R, such as its features, data types, categorisation, operators, vectors, matrices, data frames, functions and the R profiler
- Explains basic and advanced statistical concepts such as measures of central value, dispersion and shape; sampling distribution; correlation coefficient and regression analysis; inference, ANOVA, machine learning concepts and text mining, and how to implement them in R
- Includes numerous examples and program code
- Provides multiple choice, programming and concept-based questions at the end of every chapter
- Provides access to an App for additional material on Android mobile phones
- Online resources are available at www.universitiespress.com/rprogramming

**Sandhya Arora** is Professor at the Department of Computer Engineering, MKSSS's Cummins College of Engineering for Women, Pune. A Ph.D. from Jadavpur University, Kolkata, she has more than 22 years of teaching experience and has published papers in acclaimed international journals.

**Latesh Malik** is Associate Professor and Head of the Department of Computer Science & Engineering, Government College of Engineering, Nagpur. A Ph.D. from Visvesvaraya National Institute of Technology, Nagpur, and a gold medalist in M.Tech. and B.E, she has more than 22 years of teaching experience and has published more than 100 papers in international journals.

*Preface*

*Acknowledgements*

**Chapter 1: Introduction to R Programming **

*Objectives*

1.1 Overview of R

1.2 Installation of R

1.3 Installation and Loading of R Packages

1.4 R – Basic Syntax

1.5 Data Types and Objects

1.6 Variables

1.7 Constants

1.8 Comments

1.9 Debugging in R

*Exercises*

**Chapter 2: Data Definitions and Categorisation **

*Objectives*

2.1 Overview of Data

2.2 Sources of Data

2.3 Big Data

2.4 Data Categorisation

2.5 Data Cube

*Exercises*

**Chapter 3: Operators **

*Objectives*

3.1 Introduction to Operators

3.2 Arithmetic Operators

3.3 Relational Operators

3.4 Logical Operators

3.5 Miscellaneous Operators

3.6 Precedence and Associativity of Operators

*Exercises*

**Chapter 4: Control Statements and Functions **

*Objectives*

4.1 Introduction

4.2 The if Statement

4.3 The for Statement

4.4 The while Loop

4.5 The repeat and break Statements

4.6 The next Statement

4.7 The switch Statement

4.8 Functions

4.9 Some Solved Examples

*Exercises*

**Chapter 5: Interfacing with R **

*Objectives*

5.1 Introduction to Extending R

5.2 Interfacing R with C/C++

5.3 Interfacing R with Python

*Exercises*

**Chapter 6: Vectors **

*Objectives*

6.1 Overview of Vectors

6.2 Creating a Vector

6.3 Accessing the Elements of a Vector

6.4 Vector Manipulation and Vector Arithmetic

6.5 Deleting a Vector

6.6 Vector Element Sorting

*Exercises*

**Chapter 7: Matrices **

*Objectives*

7.1 Creating a Matrix

7.2 Coercion of Matrix Elements

7.3 Matrix Subsetting

7.4 Matrix Operations

7.5 Combining Matrices

7.6 Special Matrices

7.7 Eigenvectors and Eigenvalues

7.8 Arrays

*Exercises*

**Chapter 8: Lists **

*Objectives*

8.1 Introduction to Lists

8.2 Creating a List

8.3 General List Operations

8.4 Accessing the Elements of a List

8.5 Manipulating the Elements of a List

8.6 Merging Lists

8.7 Applying Functions to a List

8.8 Recursive List

8.9 Sorting and Searching

*Exercises*

**Chapter 9: Data Frames **

*Objectives*

9.1 Introduction to Data Frames

9.2 Creating a Data Frame

9.3 General Operations on Data Frames

9.4 Expanding a Data Frame

9.5 Applying Functions to Data Frames

*Exercises*

**Chapter 10: Factors and Tables **

*Objectives*

10.1 Introduction to Factors

10.2 Creating a Factor

10.3 Factor Levels

10.4 Summarising a Factor

10.5 Ordered Factors

10.6 Converting Factors

10.7 Common Functions Used with Factors

10.8 Introduction to Tables and Creating Tables

10.9 Table-related Functions

10.10 Cross-tabulation

*Exercises*

**Chapter 11: Regular Expressions and String Manipulation in R**

*Objectives*

11.1 Introduction to Regular Expressions

11.2 Regular Expressions and Pattern Matching

11.3 String Manipulation

11.4 Solved Examples of Regular Expressions

*Exercises*

**Chapter 12: S3 and S4 Classes and Objects **

*Objectives*

12.1 Introduction to S3 and S4 Classes and Objects

12.2 S3 Classes

12.3 S4 Classes

*Exercises*

**Chapter 13: Accessing Input and Output **

*Objectives*

13.1 Introduction to Files and Input/Output

13.2 Accessing the Keyboard and Monitor

13.3 File Functions

*Exercises*

**Chapter 14: Graphs in R Programming **

*Objectives*

14.1 Introduction to Graphs

14.2 Creating Graphs

14.3 Histograms and Density Plots

14.4 Dot Plots

14.5 Bar Plots

14.6 Line Charts

14.7 Pie Charts

14.8 Box Plots

14.9 Scatter Plots

14.10 Saving Graphs to a File

14.11 Creating Three-Dimensional Plots

*Exercises*

**Chapter 15: R Apply Family **

*Objectives*

15.1 Introduction to the Apply Family

15.2 The apply() Function

15.3 The lapply() Function

15.4 The sapply() Function

15.5 Slicing a Vector

15.6 The tapply() Function

15.7 The rep() Function

15.8 The mapply() Function

15.9 The vapply() Function

*Exercises*

**Chapter 16: The R Profiler **

*Objectives*

16.1 Introduction

16.2 Using the system.time() Function

16.3 Timing Longer Expressions

16.4 Using the R Profiler

16.5 Using the summaryRprof() Function

*Exercises*

**Chapter 17: Descriptive Statistics using R **

*Objectives*

17.1 Introduction to Statistical Analysis in R

17.2 Measures of Central Tendency or Location

17.3 Measures of Dispersion

17.4 Measures of Shape

*Exercises*

**Chapter 18: Probability **

*Objectives*

18.1 Introduction to Probability

18.2 Probability and Statistics

18.3 Random Variables

18.4 Probability Distribution

*Exercises*

**Chapter 19: Sampling Distributions **

*Objectives*

19.1 Introduction to Sampling Distributions

19.2 Central Limit Theorem

19.3 Sampling Distribution of *X*2

19.4 Student’s T Distribution

19.5 F Distribution

*Exercises*

**Chapter 20: Correlation and Regression Analysis **

*Objectives*

20.1 Introduction to Correlation and Regression Analysis

20.2 Correlation Analysis

20.3 Regression Analysis

*Exercises*

**Chapter 21: Statistical Inference **

*Objectives*

21.1 Introduction to Statistical Inference

21.2 Hypothesis Testing

*Exercises*

**Chapter 22: Analysis of Variance **

*Objectives*

22.1 Introduction to Analysis of Variance

22.2 Implementing Analysis of Variance

22.3 Variants of ANOVA

22.4 ANOVA in R

*Exercises*

**Chapter 23: Machine Learning Algorithms in R **

*Objectives*

23.1 Introduction to Machine Learning Algorithms

23.2 Naive Bayes Classifier

23.3 Decision Tree Classifier

23.4 The k-Nearest Neighbour Method

23.5 Clustering Techniques: K-means Clustering

23.6 Association Rule Mining

*Exercises*

**Chapter 24: Text Mining in R: Sentiment Analysis **

*Objectives*

24.1 Introduction to Text Mining

24.2 Text Preprocessing

24.3 Sentiment Analysis

24.4 N-grams

*Exercises *

*Index*