- Libraries are packages that provide functions.
- We use:
- ggplot2 → for plotting graphs
- dplyr → for data manipulation
- tidyr → for reshaping data
- ggrepel → to avoid overlapping labels
The dataset is loaded using read.csv()
It reads data from a file into R
Raw data cannot be directly used for slope chart
We calculate average values for each group
Explanation:
group_by() → separates data into groups
summarise() → calculates mean values
na.rm = TRUE → removes missing values
Data is converted from wide format to long format
Required for ggplot slope chart
Explanation:
pivot_longer() → reshapes data
Makes it easier to plot multiple variables
Explanation:
geom_line() → connects values
geom_point() → marks data points
geom_text_repel() → avoids overlapping labels
labs() → adds title and axis labels
Glucose is higher in diabetic patients
BMI shows increasing trend
Age is slightly higher in diabetic group
Insulin varies significantly
Blood Pressure shows minor variation
Slope chart effectively compares two groups
Diabetic patients show higher health risk indicators
Visualization improves understanding of patterns