library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
heart_csv <- read.csv("/Users/oluwatonioshuntolu/Desktop/MATH58/heart (1).csv") |>
  mutate(
    Sex = ifelse(Sex == 1, "Male", "Female"),
    HeartDisease = factor(HeartDisease, levels = c("Presence", "Absence"))
  )

p <- ggplot(heart_csv, aes(x = Age, y = Cholesterol,
                            color = HeartDisease,
                            text = paste("Age:", Age,
                                         "<br>Cholesterol:", Cholesterol,
                                         "<br>Sex:", Sex,
                                         "<br>Cholesterol:", Cholesterol))) +
  geom_point(alpha = 0.7) +
  scale_color_manual(values = c("Presence" = "#e03131", 
                                "Absence"  = "#2f9e44")) +
  labs(x = "Age", y = "Cholesterol", color = "Heart Disease") +
  theme_minimal()

ggplotly(p, tooltip = "text")