LA-1 Report

Author

Akhilesh N R,Balachandra V Hunashikatti

Step1 : Load the necessary Libraries

library(ggplot2)
library(ggbump)
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: Create and explore the Dataset

data <- data.frame(
  Company = c("Amazon", "Apple Inc.", "Alphabet (Google)", "Microsoft Corporation",
              "Meta Platforms", "Tesla", "Intel Corporation", "Cisco Systems Inc.",
              "Oracle Corporation", "Salesforce Inc."),
  Revenue = c(513.98, 387.53, 282.83, 204.09, 116.6, 81.46, 63.05, 53.16, 46.07, 31.35)
)

Step 3: Assigning the Revenue Ranks

data <- data %>%
  arrange(desc(Revenue)) %>%
  mutate(Rank = row_number())


bump_data <- data %>%
  mutate(Year = 2023) %>%
  select(Company, Year, Rank)

Step 4: Simulate Two Time Points

bump_data <- bump_data %>%
  bind_rows(bump_data %>% mutate(Year = 2022)) %>%
  arrange(Company, Year)
print(bump_data)
                 Company Year Rank
1      Alphabet (Google) 2022    3
2      Alphabet (Google) 2023    3
3                 Amazon 2022    1
4                 Amazon 2023    1
5             Apple Inc. 2022    2
6             Apple Inc. 2023    2
7     Cisco Systems Inc. 2022    8
8     Cisco Systems Inc. 2023    8
9      Intel Corporation 2022    7
10     Intel Corporation 2023    7
11        Meta Platforms 2022    5
12        Meta Platforms 2023    5
13 Microsoft Corporation 2022    4
14 Microsoft Corporation 2023    4
15    Oracle Corporation 2022    9
16    Oracle Corporation 2023    9
17       Salesforce Inc. 2022   10
18       Salesforce Inc. 2023   10
19                 Tesla 2022    6
20                 Tesla 2023    6

Step 5: Plot the Bump Chart

ggplot(bump_data, aes(x = Year, y = Rank, group = Company, color = Company)) +
  geom_bump(size = 2) +                          # Bump line
  geom_point(size = 4) +                         # Circle at each point
  geom_text(data = bump_data %>% filter(Year == 2023),
            aes(label = Company), hjust = -0.1, size = 3) +  # Labels at the end
  scale_y_reverse(breaks = 1:10) +               # Reverse rank (1 at top)
  scale_x_continuous(breaks = c(2022, 2023), limits = c(2022, 2023.3)) +
  labs(title = "Top 10 Tech Companies by Revenue (2022–2023)",
       subtitle = "Simulated bump chart using a single year of data",
       x = "Year", y = "Rank (1 = Highest Revenue)") +
  theme_minimal() +
  theme(legend.position = "none")               # Hide legend
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.