LA-1 REPORT

Author

Puneeth, Tarun

STEP1:Load neccessary libraries

# Step 1: Install ggplot2 if not already installed
if (!require(ggplot2)) install.packages("ggplot2", dependencies = TRUE)
Loading required package: ggplot2

Step-2: Load ggplot2

library(ggplot2)

Step-3:create sample DDP data

gdp_data <- data.frame(
  State = c("Maharashtra", "Tamil Nadu", "Uttar Pradesh", "Gujarat", "Karnataka",
            "West Bengal", "Rajasthan", "Andhra Pradesh", "Madhya Pradesh", "Bihar"),
  GDP = c(35.3, 24.8, 23.5, 22.5, 21.1, 16.7, 12.5, 11.6, 11.2, 9.8) # In lakh crore INR
)
Step-4: sort data manually (base-R) for plotting
gdp_data <- gdp_data[order(gdp_data$GDP), ]
gdp_data$State <- factor(gdp_data$State, levels = gdp_data$State)
Step-5: create lollipop chart
ggplot(gdp_data, aes(x = State, y = GDP)) +
  geom_segment(aes(x = State, xend = State, y = 0, yend = GDP), color = "skyblue", size = 1.5) +
  geom_point(color = "blue", size = 4) +
  coord_flip() +
  labs(title = "GDP Comparison Across Indian States (Sample Data)",
       x = "State",
       y = "GDP (Lakh Crore INR)") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5, size = 16, face = "bold"))
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.