PROJECT

Author

BALAJI/Manjunath B R

Objective

Consturct a Correlation network graph for a health dataset showing variable associations

Step 01: Load the required Libraries.

# Step 01 :- Load the required Libraries.
library(ggplot2)
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

Step 02 :- Creating the dataset.

# Step 02 :- Create a data frame for health indicators across two time periods.
health_data <- data.frame(
  Indicator = rep(c("Blood Pressure", "Cholesterol", "BMI", "Heart Rate", "Blood Sugar"), each = 2),
  Time = rep(c("Before", "After"), times = 5),
  Value = c(140, 125, 220, 190, 28, 26, 85, 78, 160, 140)
)

Step 03 :- Plot a Slope Chart.

# Step 03 :- Plot a Slope chart.
ggplot(health_data, aes(x = Time, y = Value, group = Indicator, color = Indicator)) +
  geom_line(size = 1.2) +
  geom_point(size = 3) +
  geom_text(data = health_data %>% filter(Time == "Before"),
            aes(label = paste(Indicator, Value, sep = ": ")),
            hjust = 1.1) +
  geom_text(data = health_data %>% filter(Time == "After"),
            aes(label = paste(Indicator, Value, sep = ": ")),
            hjust = -0.1) +
  theme_minimal() +
  theme(legend.position = "none") +
  ggtitle("Health Indicators Comparison Before and After Treatment") +
  scale_x_discrete(expand = expansion(add = c(0.2, 0.2)))
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.