R - PROGRAMMING
Semester IV
Course code
Category Professional Core Courses
Course title R - Programming
Scheme and Credits L T P Credits
3 0 0 3
Classwork 30 Marks
Exam 70 Marks
Total 100 Marks
Duration of Exam 03 Hours
Note: The examiner will set nine questions in total. Question one will be compulsory. Question
one will have seven parts of 2 marks each from all units, and the remaining eight questions of 14
marks each to be set by taking two questions from each unit. The students have to attempt five
questions in total, the first being compulsory and selecting one from each unit.
COURSE OBJECTIVES:
1. Learn Fundamentals of R.
2. Covers how to use different functions in R, how to read data into R, accessing R packages,
writing R functions, debugging, and organizing data using R functions.
3. Cover the Basics of statistical data analysis with examples.
4. The whole syllabus will give an idea to collect, compile and visualize data using statistical
functions.
UNIT - I
Introduction to R: What is R? – Why R? – Advantages of R over Other Programming Languages
- R Studio: R command Prompt, R script file, comments.
Handling Packages in R: Installing a R Package, Few commands to get started:
[Link](), [Link](), help(), [Link](), library() - Input and Output –
Entering Data from keyboard.
R - Data Types: Vectors, Lists, Matrices, Arrays, Factors, Data Frame.
R - Variables: Variable assignment, Data types of Variable, Finding Variable ls(), Deleting
Variables
UNIT - II
R - Operators: Arithmetic Operators, Relational Operators, Logical Operator, Assignment
Operators, Miscellaneous Operators.
R - Decision Making: if statement, if – else statement, if – else if statement, switch statement.
R - Loops: repeat loop, while loop, for loop - Loop control statement: break statement, next
statement.
R - Function: function definition,Built-inn functions: mean(), paste(), sum(), min(), max(), seq(),
user-defined function, calling a function, calling a function without an argument, calling a function
with argument values.
UNIT - III
R – Strings: Manipulating Text in Data: substr(), strsplit(), paste(), grep(), toupper(), tolower().
R – Vectors: Sequence vector, rep function, vector access, vector names, vector math, vector
recycling, vector element sorting.
R – List: Creating a List, List Tags and Values, Add/Delete Element to or from a List, Size of List,
Merging Lists, Converting List to Vector.
R – Matrices: Accessing Elements of a Matrix, Matrix Computations: Addition, subtraction,
Multiplication and Division.
R - Arrays: Naming Columns and Rows, Accessing Array Elements, Manipulating Array
Elements, Calculation Across Array Elements.
R – Factors: creating factors, generating factor levels gl().
R - Data Frames: Create Data Frame, Data Frame Access, Understanding Data in Data Frames:
dim(), nrow(), ncol(), str(), Summary(), names(), head(), tail(), edit() functions - Extract Data from
Data Frame, Expand Data Frame: Add Column, Add Row - Joining columns and rows in a Data
frame rbind() and cbind() – Merging Data frames merge() – Melting and Casting data melt(),
cast().
UNIT - IV
Loading and handling Data in R: Getting and Setting the Working Directory – getwd(), setwd(),
dir() - R-CSV Files - Input as a CSV file, Reading a CSV File, Analyzing the CSV File:
summary(), min(), max(), range(), mean(), median(), apply() - Writing into a CSV File – R -Excel
File – Reading the Excel file.
Data Visualization through various plots and charts: bar charts, histogram, frequency polygon,
density plots, scatter plots, box & whisker plots, heat and contour plots, plotting the above graphs
in R, plotting with package ggplot2.
COURSE OUTCOMES:
At the end of this course, students will demonstrate the ability to
CO1: outline concepts related to R programming and data analysis.
CO2: explain the basic concepts and tools that are used to solve problems in data analytics.
CO3: apply R programming for reading, cleaning, visualizing and analysing data.
CO4: analyse the trends in data through exploratory data analysis.
CO5: Understands the loading, retrieval techniques of data.
CO6: Minimize and maximize functions simulation and visualization and statistical analysis
using R.
TEXT AND REFERENCE BOOKS:
1. W. N. Venables, D. M. Smith and the R core Team, An introduction to R, Notes on R: A
Programming Environment for Data Analysis and Graphics, version 3.3.2, 2016.
2. Saroj Dahiya Ratnoo and Himmat Singh Ratnoo, Essentials of R for Data Analytics, Wiley,
2021.
3. Hadley Wickham and Garrett Grolemund, R for Data Science Import, Tidy, Transform and
model Data, O’Reilly, 2017.
4. Paul Teeter, R Cookbook, O’Reilly, 2011.
5. Gareth James, Daniela Witten, Trevor Hastie, Robert Tibshirani, An Introduction to Statistical
Learning with Applications in R, Springer, 2013.
6. Han, J., Kamber, M, Pei, J., Data Mining Concepts and Techniques, Third edition, Morgan
Kaufmann, 2012.