1. Introduction to R
History of R: R was developed by Ross Ihaka and Robert Gentleman in 1993 as a programming
language and environment for statistical computing and graphics.
Characteristics of R: R is widely used in data analysis, statistical modeling, and data visualization,
offering a rich ecosystem of packages and libraries.
R vs Python: R is known for its strength in statistical analysis and visualization, while Python is more
versatile for general programming and machine learning tasks.
2. Data Types in R
Basic Data Types: R supports basic data types like numeric, character, logical (boolean), and factor
for categorical data.
Vectors: Vectors are the most basic data structures in R, representing ordered collections of data
elements of the same type.
Data Frames: Data frames are two-dimensional structures used for storing tabular data, with rows
and columns similar to a table or spreadsheet.
3. Control Flow in R
If-Else Statements: R supports conditional statements using if, else if, and else for decision-making.
Loops: R provides for loops and while loops for iterative execution of code blocks.
Apply Functions: R includes the apply family of functions (apply, lapply, sapply) for applying a
function over a collection of data elements.
4. Functions in R
Function Declaration: Functions in R are declared using the function keyword, and can return values
or perform operations on data.
Default Arguments: R allows for setting default values for function arguments, making functions
more flexible and reusable.
Anonymous Functions: R supports anonymous (lambda) functions, which can be passed as