LA-1 Presentation

Author

Akhilesh N R ,Balachandra V Hunashikatti

Problem Statement : Build a bump chart showing changes in tech company ranking based on revenue over 5 years

📌 Objective

To visualize the ranking of top tech companies based on their 2022–2023 revenue using a simulated bump chart in R.

Step 1 : Load Required 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

ggplot2 is used to create layered and customizable data visualizations

ggbump extends ggplot2 to create bump charts that show ranking changes.

dplyr is used to manipulate and prepare data efficiently (e.g., sorting, ranking).

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)
)

This R code creates a data frame called data with two columns: “Company” and “Revenue.” The “Company” column contains the names of 10 major tech companies. The “Revenue” column holds the corresponding revenue values in billions. This data frame is structured to facilitate analysis or visualization of company revenue data.

Step 3: Assigning the Revenue Ranks

# Arrange the data in descending order of Revenue and assign a rank
data <- data %>%
  arrange(desc(Revenue)) %>%
  mutate(Rank = row_number())

# Add a 'Year' column set to 2023 and select only relevant columns for the bump chart
bump_data <- data %>%
  mutate(Year = 2023) %>%
  select(Company, Year, Rank)

This R code processes the data data frame using the dplyr package. First, it arranges the data by descending revenue (arrange(desc(Revenue))) and adds a new column, “Rank,” based on the row number after sorting (mutate(Rank = row_number())). Next, it creates a new data frame, bump_data, by adding a “Year” column with the value 2023 (mutate(Year = 2023)) and selecting only the “Company,” “Year,” and “Rank” columns (select(Company, Year, Rank)).

Step 4: Simulate Two Time Points

# Duplicate the data for the year 2022 and combine it with the existing 2023 data
bump_data <- bump_data %>%
  bind_rows(bump_data %>% mutate(Year = 2022)) %>%
  arrange(Company, Year)  # Sort the combined data by Company and Year

# Display the final dataset with both years
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

This R code simulates two time points (2022 and 2023) for the bump_data data frame.

  1. bind_rows(bump_data %>% mutate(Year = 2022)): This part duplicates the bump_data by creating a new version with the “Year” column set to 2022. The bind_rows() function combines this new data with the original bump_data, effectively adding the same data for the year 2022.

  2. arrange(Company, Year): After combining the data, it sorts the rows first by “Company” and then by “Year” to ensure the data is ordered correctly for both years.

The resulting bump_data now contains rows for both 2022 and 2023 for each company, allowing for comparison across the two years.

Step 5: Plot the Bump Chart

ggplot(bump_data, aes(x = Year, y = Rank, group = Company, color = Company)) +
  geom_bump(size = 2) +                         # Draw rank lines
  geom_point(size = 4) +                        # Add points at each year
  geom_text(data = bump_data %>% filter(Year == 2023),
            aes(label = Company), hjust = -0.1, size = 3) +  # Label companies in 2023
  scale_y_reverse(breaks = 1:10) +              # Rank 1 at the top
  scale_x_continuous(breaks = c(2022, 2023), limits = c(2022, 2023.3)) +  # Set x-axis
  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.

This R code creates a bump chart to visualize the change in rankings of the top 10 tech companies between 2022 and 2023 based on simulated revenue data.

  1. ggplot(bump_data, aes(x = Year, y = Rank, group = Company, color = Company)): Initializes the plot, mapping “Year” to the x-axis, “Rank” to the y-axis, and differentiating companies by color and group.

  2. geom_bump(size = 2): Adds the bump line connecting the companies’ ranks across the years, with a line width of 2.

  3. geom_point(size = 4): Adds points at each year’s data to represent company ranks visually.

  4. geom_text(): Labels the companies at the end of the 2023 line, positioning them slightly to the left of the point for clarity.

  5. scale_y_reverse(breaks = 1:10): Reverses the y-axis so that the highest rank (1) appears at the top.

  6. scale_x_continuous(breaks = c(2022, 2023), limits = c(2022, 2023.3)): Sets the x-axis to only show 2022 and 2023.

  7. labs(): Adds titles and axis labels to the plot.

  8. theme_minimal(): Applies a minimalistic theme to the plot

  9. theme(legend.position = "none"): Removes the legend for clarity, as the colors already indicate the companies.

The resulting plot visually compares the rankings of companies across the two years, highlighting the changes in their positions.

📈 Understanding the Outcomes

  • Stable Rankings: Companies like Amazon, Apple, and Alphabet (Google) maintain their top positions (Rank 1 to 3) from 2022 to 2023, with no significant change in their rankings.

  • Minimal Movement: Other companies, such as Microsoft, Meta, Tesla, and Intel, also retain their positions between 2022 and 2023, showing stability in their revenue rankings.

  • Clear Visualization: The bump lines show how each company’s rank remains consistent across the two years. The points at each year help track the specific rank for each company, with labels added to highlight the companies in 2023.

  • Key Insight: The data suggests that the top tech companies by revenue have relatively stable market positions, with few changes in their rankings over this short time period.

  • Overall Trend: There is a lack of major fluctuations in rankings, indicating a stable competitive landscape for these companies during the years 2022 and 2023.

📚 Conclusion

The bump chart highlights the stability of the top 10 tech companies by revenue between 2022 and 2023. The rankings show minimal movement, with companies like Amazon, Apple, and Alphabet (Google) maintaining their positions at the top. The consistency in the rankings suggests that these companies are firmly established in their market positions, with no significant changes in their relative performance over this short time span. This indicates a stable competitive environment, where the leading companies continue to dominate the market.