Analytics is the systematic use of data, statistical methods, and computational tools to extract
insight that supports decision‑making. It is structured, computational, and focused on answering
business questions.
● Descriptive Analytics — summarizes historical data to understand what happened.
Example: average sales last month, number of customers per day.
● Predictive Analytics — uses patterns in historical data to estimate what will happen.
Example: predicting next month’s sales using regression.
● Prescriptive Analytics — recommends actions to achieve the best outcome.
Example: optimizing delivery routes to minimize cost.
Data Science Workflow
1. Problem Identification
2. Data Acquisition
3. Data Wrangling
4. Analysis and Modeling
5. Reporting or Deployment
Key Terms
●
●
●
●
Data — raw facts
Statistics — summaries of data
Model — mathematical representation
Variable — named container for data
2. R and RStudio Essentials
R vs. RStudio
● R: programming language
● RStudio: IDE that organizes your workflow
RStudio Components
Console, Source Pane, Environment Pane, History Pane, Files, Plots, Packages, Help.
How Functions Work
A function has a name, arguments, and a return value.
Example
None
sqrt(100)
Returns:
None
[1] 10
Example with multiple arguments
None
log(x = 8, base = 2)
Returns:
None
[1] 3
3. R Syntax and Data Types
Assignment
None
x <- 7
Comments
None
# This is a comment
Arithmetic
None
12 + 23
# 35
15 / 2
# 7.5
2^4
# 16
Data Types
Character, Numeric, Integer, Logical, Complex.
Checking Types
None
class(7)
# "numeric"
typeof(7L)
# "integer"
Converting Types
None
as.integer(3.9)
# 3
as.character(5)
# "5"
Dates
None
date()
# "Wed Mar 4 01:03:00 2026"
Sys.Date()
# "2026-03-04"
4. R Data Structures
Vectors
Creating vectors
None
x <- c(1, 2, 3)
1:5
rep(1, 3)
Indexing
None
x[1]
# 1
x[2:3]
# 2 3
Vectorized operations
None
x * 2
# 2 4 6
sqrt(x)
# 1.0 1.41 1.73
Lists
None
y <- list("a", 1L, 1.5, TRUE)
y[[3]]
# 1.5
str(y)
Matrices and Arrays
Two‑dimensional or multi‑dimensional structures.
Data Frames
Creating
None
df <- data.frame(name = c("A","B"), score = c(90, 85))
Accessing
None
df$name
df[1,2]
Renaming
None
names(df) <- c("Student","Score")
5. Version Control: Git, GitHub, GitKraken
Key Concepts
Repository, Commit, Branch, Fork, Clone, Pull, Push, Pull Request.
Workflow
Fork → Clone → Edit → Stage → Commit → Push → Pull Request.
6. Conditionals and Logic in R
Relational Operators
None
5 < 10
# TRUE
5 == 5
# TRUE
5 != 3
# TRUE
Logical Operators
None
TRUE & FALSE
# FALSE
TRUE | FALSE
# TRUE
!TRUE
# FALSE
if statement
None
x <- 5
if (x > 0) {
"Positive"
}
if‑else
None
x <- -3
if (x > 0) {
"Positive"
} else {
"Negative"
}
Chained if
None
x <- 0
if (x > 0) {
"Positive"
} else if (x < 0) {
"Negative"
} else {
"Zero"
}
7. Loops in R
For loop
None
names <- c("Mike","Lucy","John")
for (n in names) {
print(n)
}
Sum of first 100 even numbers
None
sum <- 0
for (i in 1:100) {
sum <- sum + i*2
}
sum
Returns:
None
[1] 10100