library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final
#1 Create a histogram of age distribution for individuals with and without heart disease
ggplot(data1, aes(x = age, fill = target)) +
  geom_histogram(binwidth = 5, position = "dodge", color = "black") +
  labs(title = "Age Distribution by Heart Disease Status",
       x = "Age",
       y = "Frequency",
       fill = "Heart Disease") +
  theme_minimal()
## Warning: The following aesthetics were dropped during statistical transformation: fill.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final
#2 Create a bar plot of heart disease distribution among different genders
ggplot(data1, aes(x = factor(sex), fill = target)) +
  geom_bar(position = "dodge") +
  labs(title = "Heart Disease Distribution by Gender",
       x = "Gender",
       y = "Number of Cases",
       fill = "Heart Disease") +
  scale_x_discrete(labels = c("Female", "Male")) +
  theme_minimal()
## Warning: The following aesthetics were dropped during statistical transformation: fill.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final

#3 Create a bar plot to visualize the frequency of each chest pain type for individuals with and without heart disease
ggplot(data1, aes(x = factor(oldpeak), fill = target)) +
  geom_bar(position = "dodge") +
  labs(title = "OLDPEAK",
       x = "old",
       y = "Frequency",
       fill = "Heart Disease") +
  scale_x_discrete(labels = c("Typical Angina", "Atypical Angina", "Non-anginal Pain", "Asymptomatic")) +
  theme_minimal()
## Warning: The following aesthetics were dropped during statistical transformation: fill.
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
##   the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
##   variable into a factor?

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final
#5 Create a boxplot to compare the distribution of resting blood pressure
ggplot(data1, aes(x = target, y = resting_bp_s)) +
  geom_boxplot() +
  labs(title = "Distribution of Resting Blood Pressure by Heart Disease Status",
       x = "Heart Disease",
       y = "Resting Blood Pressure") +
  theme_minimal()
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final
#7 Create a boxplot to compare the distribution of resting blood pressure
ggplot(data1, aes(x = target, y = cholesterol)) +
  geom_boxplot() +
  labs(title = "Distribution of Resting Blood Pressure by Heart Disease Status",
       x = "Heart Disease",
       y = "Resting Blood Pressure") +
  theme_minimal()
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final

#8 Create a boxplot to compare the distribution of resting blood pressure
ggplot(data1, aes(x = target, y = ST_slope)) +
  geom_boxplot() +
  labs(title = "Distribution of Resting Blood Pressure by Heart Disease Status",
       x = "Heart Disease",
       y = "Resting Blood Pressure") +
  theme_minimal()
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final
#9 Create a boxplot to compare the distribution of resting blood pressure
ggplot(data1, aes(x = target, y = exercise_angina)) +
  geom_boxplot() +
  labs(title = "Distribution of Resting Blood Pressure by Heart Disease Status",
       x = "Heart Disease",
       y = "Resting Blood Pressure") +
  theme_minimal()
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final

#10 Create a boxplot to compare the distribution of resting blood pressure
ggplot(data1, aes(x = target, y = fasting_blood_sugar)) +
  geom_boxplot() +
  labs(title = "Distribution of Resting Blood Pressure by Heart Disease Status",
       x = "Heart Disease",
       y = "Resting Blood Pressure") +
  theme_minimal()
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final

#11 Create a boxplot to compare the distribution of resting blood pressure
ggplot(data1, aes(x = target, y = age)) +
  geom_boxplot() +
  labs(title = "Distribution of Resting Blood Pressure by Heart Disease Status",
       x = "Heart Disease",
       y = "Resting Blood Pressure") +
  theme_minimal()
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final
#12 Check the column names in your dataset
names(data1)
##  [1] "age"                 "sex"                 "chest_pain_type"    
##  [4] "resting_bp_s"        "cholesterol"         "fasting_blood_sugar"
##  [7] "resting_ecg"         "max_heart_rate"      "exercise_angina"    
## [10] "oldpeak"             "ST_slope"            "target"
# Replace 'serum_cholesterol' with the correct column name in the dataset
# Create a boxplot to compare the distribution of serum cholesterol levels
ggplot(data1, aes(x = target, y = cholesterol)) +
  geom_boxplot() +
  labs(title = "Distribution of Serum Cholesterol Levels by Heart Disease Status",
       x = "Heart Disease",
       y = "Serum Cholesterol Levels") +
  theme_minimal()
## Warning: Continuous x aesthetic
## ℹ did you forget `aes(group = ...)`?

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final
#13 Create a scatterplot to explore the relationship between age and heart disease
ggplot(data1, aes(x = age, y = target)) +
  geom_point() +
  labs(title = "Age and Heart Disease Relationship",
       x = "Age",
       y = "Heart Disease (0 = No, 1 = Yes)") +
  theme_minimal()

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final
#14 Create a scatterplot to visualize the relationship between age and maximum heart rate achieved
ggplot(data1, aes(x = age, y = max_heart_rate)) +
  geom_point() +
  labs(title = "Age and Maximum Heart Rate Achieved",
       x = "Age",
       y = "Maximum Heart Rate Achieved") +
  theme_minimal()

library(ggplot2)
library(readr)
heart_statlog_cleveland_hungary_final <- read_csv("heart_statlog_cleveland_hungary_final.csv")
## Rows: 1190 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (12): age, sex, chest_pain_type, resting_bp_s, cholesterol, fasting_bloo...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data1<- heart_statlog_cleveland_hungary_final
#15 Create a grouped bar plot to visualize the distribution of gender among different age groups
ggplot(data1, aes(x = age, fill = factor(sex))) +
  geom_bar(position = "dodge") +
  labs(title = "Gender Distribution Among Different Age Groups",
       x = "Age Group",
       y = "Count",
       fill = "Gender") +
  theme_minimal()