Load the dataset
df <- read.csv(“/Users/sreedharravipalli/DAT 301 Lab
1/Absenteeism_at_work.csv”, sep = “;”, header = TRUE)
Question 1: Scatter plot of Height vs. Weight
x <- df\(Weight
y <- df\)Height plot(x, y, pch = 16, xlab = “Weight”, ylab =
“Height”, main = “Height vs Weight”)
Correlation between height and weight
cor(x, y, use = “complete.obs”)
Question 2: Histogram of absenteeism hours
Hours <- df$Absenteeism.time.in.hours hist(Hours, main =
“Histogram of Absent Hours”)
Question 3: Histogram of Age
Age <- df$Age hist(Age, main = “Histogram of Age of person
corresponding of each absences”, breaks = 100)
Question 4: Bar plot of absenteeism by month
df\(Month.of.absence <-
as.factor(df\)Month.of.absence) counts <- tapply(df\(Absenteeism.time.in.hours,
df\)Month.of.absence, sum, na.rm = TRUE) barplot(counts, main =
“Hours of Absence by Month”, xlab = “Month”, ylab = “Hours”)
Question 5: Box plot for Social Smoker
boxplot(df\(Absenteeism.time.in.hours ~
df\)Social.smoker, col = c(“red”, “blue”), xlab = “Social Smoker
(0 = No, 1 = Yes)”, ylab = “Hours Absent”, main = “Box Plot of Hours
Absent by Social Smoker”)
Question 6: Box plot for Social Drinker
boxplot(df\(Absenteeism.time.in.hours ~
df\)Social.drinker, col = c(“red”, “blue”), xlab = “Social
Drinker (0 = No, 1 = Yes)”, ylab = “Hours Absent”, main = “Box Plot of
Hours Absent by Social Drinkers”)