BUMP CHART FOR RANKING CHANGES 0F TOP COMPANIES [LA 1 ASSIGNMENT]

Author

PRACHETAN MS [USN:1NT24IS152 SEC:‘C’] AND JAYANTH Y [USN:1NT24IS094 SEC: ‘B’]

Objective

To generate a bump chart using ggplot2 to visualize ranking changes of top companies over multiple years based on revenue.

Step 1: Load required packages

We use ggplot2 for visualization and dplyr, tidyr for data manipulation.

#install.packages("ggplot2")
#install.packages("dplyr")
#install.packages("tidyr")

library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.5.3
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
library(tidyr)

Step 2: Load the dataset

We load the dataset containing top US tech companies and their revenue.

data <- read.csv("C:/Users/SRINIVAS MV/Downloads/archive/Top 50 US Tech Companies 2022 - 2023.csv")

head(data)
           Company.Name   Industry                  Sector   HQ.State
1            Apple Inc. Technology    Consumer Electronics California
2 Microsoft Corporation Technology Software Infrastructure Washington
3     Alphabet (Google) Technology Software Infrastructure California
4                Amazon Technology    Software Application Washington
5    NVIDIA Corporation Technology          Semiconductors California
6                 Tesla Technology Software Infrastructure      Texas
  Founding.Year Annual.Revenue.2022.2023..USD.in.Billions.
1          1976                                     387.53
2          1975                                     204.09
3          1998                                     282.83
4          1994                                     513.98
5          1993                                      26.97
6          2003                                      81.46
  Market.Cap..USD.in.Trillions. Stock.Name
1                         2.520       AAPL
2                         2.037       MSFT
3                         1.350       GOOG
4                         1.030       AMZN
5                         0.653       NVDA
6                         0.625       TSLA
  Annual.Income.Tax.in.2022.2023..USD.in.Billions. Employee.Size
1                                           18.314        164000
2                                           15.139        221000
3                                           11.356        190234
4                                           -3.217       1541000
5                                            0.189         22473
6                                            1.132        127855
str(data)
'data.frame':   50 obs. of  10 variables:
 $ Company.Name                                    : chr  "Apple Inc." "Microsoft Corporation" "Alphabet (Google)" "Amazon" ...
 $ Industry                                        : chr  "Technology" "Technology" "Technology" "Technology" ...
 $ Sector                                          : chr  "Consumer Electronics" "Software Infrastructure" "Software Infrastructure" "Software Application" ...
 $ HQ.State                                        : chr  "California" "Washington" "California" "Washington" ...
 $ Founding.Year                                   : int  1976 1975 1998 1994 1993 2003 2004 1961 1977 1984 ...
 $ Annual.Revenue.2022.2023..USD.in.Billions.      : num  388 204 283 514 27 ...
 $ Market.Cap..USD.in.Trillions.                   : num  2.52 2.037 1.35 1.03 0.653 ...
 $ Stock.Name                                      : chr  "AAPL" "MSFT" "GOOG" "AMZN" ...
 $ Annual.Income.Tax.in.2022.2023..USD.in.Billions.: num  18.314 15.139 11.356 -3.217 0.189 ...
 $ Employee.Size                                   : int  164000 221000 190234 1541000 22473 127855 86482 20000 143000 83300 ...

Step 3: Clean and prepare the data

We rename the revenue column for easier use and select the top 10 companies based on revenue.

data <- data %>%
  rename(Revenue = Annual.Revenue.2022.2023..USD.in.Billions.)

top_companies <- data %>%
  arrange(desc(Revenue)) %>%
  head(10)

Step 4: Create simulated data for multiple years

We generate revenue values for 5 years (2019–2023) using random variation.

set.seed(123)

years <- 2019:2023

bump_data <- top_companies %>%
  select(Company.Name, Revenue) %>%
  crossing(Year = years) %>%
  mutate(
    Revenue = Revenue * runif(n(), 0.7, 1.2),
    Company = Company.Name
  )

Step 5: Rank companies for each year

We assign rankings based on revenue for each year.

bump_data <- bump_data %>%
  group_by(Year) %>%
  mutate(Rank = rank(-Revenue, ties.method = "first"))

Step 6: Create the bump chart

We plot ranking changes over years using lines and points.

ggplot(bump_data, aes(x = Year, y = Rank, group = Company, color = Company)) +
  geom_line(linewidth = 1.2) +
  geom_point(size = 3) +
  scale_y_reverse() +
  labs(
    title = "Bump Chart: Company Ranking by Revenue (2019–2023)",
    subtitle = "Visualization of ranking changes over time",
    x = "Year",
    y = "Rank"
  ) +
  theme_minimal()

Bump chart: shows how rankings of companies change over time.

Lines: each line represents a company and its movement in rank.

Points: indicate the rank of each company in a specific year.

Ranking: lower rank value (1) represents higher revenue.

scale_y_reverse(): used to display rank 1 at the top.

Color grouping: each company is represented with a different color.

Aesthetics: theme_minimal() provides a clean and simple background.

Conclusion

The bump chart effectively visualizes how company rankings fluctuate over time, making it easy to compare trends and identify consistent performers or major changes.