📘 Introduction

This report analyzes the performance of 5 students in 3 subjects.
We’ll calculate their total and average marks, and visualize the results.


🧮 Data

# Create a sample data frame
students <- data.frame(
  Name = c("Samantha", "Mani", "Vijay", "Sunil", "Kajal"),
  Marks1 = c(99, 100, 98, 49, 85),
  Marks2 = c(98, 99, 95, 91, 78),
  Marks3 = c(19, 40, 48, 36, 92)
)

students
##       Name Marks1 Marks2 Marks3
## 1 Samantha     99     98     19
## 2     Mani    100     99     40
## 3    Vijay     98     95     48
## 4    Sunil     49     91     36
## 5    Kajal     85     78     92
# Add total and average columns

students$Total <- students$Marks1 + students$Marks2 + students$Marks3
students$Average <- round(students$Total / 3, 2)

students
##       Name Marks1 Marks2 Marks3 Total Average
## 1 Samantha     99     98     19   216   72.00
## 2     Mani    100     99     40   239   79.67
## 3    Vijay     98     95     48   241   80.33
## 4    Sunil     49     91     36   176   58.67
## 5    Kajal     85     78     92   255   85.00
# Load ggplot2 for graph

# Calculate total and average

students$Total <- students$Marks1 + students$Marks2 + students$Marks3
students$Average <- round(students$Total / 3, 2)

# Define pass/fail rule (average >= 50 = Pass)

students$Result <- ifelse(students$Average >= 50, "Pass", "Fail")

students
##       Name Marks1 Marks2 Marks3 Total Average Result
## 1 Samantha     99     98     19   216   72.00   Pass
## 2     Mani    100     99     40   239   79.67   Pass
## 3    Vijay     98     95     48   241   80.33   Pass
## 4    Sunil     49     91     36   176   58.67   Pass
## 5    Kajal     85     78     92   255   85.00   Pass
library(ggplot2)

ggplot(students, aes(x = Name, y = Total, fill = Name)) +
geom_bar(stat = "identity") +
theme_minimal() +
labs(title = "Total Marks by Student", y = "Total Marks", x = "Student Name")