library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
dataset <-read_delim("C:/Users/Akshay Dembra/Downloads/Stats_Selected_Dataset/diabetes_binary_5050split_health_indicators_BRFSS2015_1.csv" , delim = ",")
## Rows: 70692 Columns: 22
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (22): Diabetes_binary, HighBP, HighChol, CholCheck, BMI, Smoker, Stroke,...
## 
## ℹ 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.
dataset
  1. Mean, Median of BMI.

  2. standard deviation of BMI.

    min_ur<- min(dataset$`BMI`)
    min_ur
    ## [1] 12
max_ur<- max(dataset$`BMI`)
max_ur
## [1] 98
mean_ur <- mean(dataset$`BMI`)

mean_ur
## [1] 29.85699
med_ur<-median(dataset$`BMI`)
med_ur
## [1] 29
sd_ur<-sd(dataset$`BMI`)
sd_ur
## [1] 7.113954

The analysis of physical activity levels and their corresponding statistics reveals the following trends:

This indicates that higher physical activity levels are associated with a slightly lower mean and median BMI, suggesting a potential relationship between increased physical activity and healthier BMI levels.

# Histogram for "Poor Mental Health(1-30)"
ggplot(dataset, aes(x = dataset$'MentHlth')) +
  geom_histogram(binwidth = 1, fill = "purple", color = "black") +
  labs(title = "Number of Days People Suffer from Mental Health Issues", x = "Poor Mental Health(1-30)", y = "Frequency")

Let’s examine the impact of heavy alcohol consumption on BMI, we will analyze BMI data specifically for individuals who consume alcohol heavily.

# Load the ggplot2 library
library(ggplot2)

ggplot(dataset, aes(x = factor(Diabetes_binary), y = MentHlth)) +
  geom_boxplot() +
  labs(
    title = "Mental Health by Diabetes Binary",
    x = "Diabetes (0 = No, 1 = Yes)",
    y = "Days of Poor Mental Health"
  ) +
  theme_minimal()