US Tech firms around the globe are grappling with the economic slowdown. Slow consumer spending, higher interest rates by central banks, and a strong dollar overseas are hinting towards a possible recession, and tech firms have started laying off employees. Meta recently fired 13% of its workforce, which amounts to more than 11,000 employees, due to this economic slowdown.
Based on the recent layoffs dataset, I would like to approach my project in following four ways:
US companies analysis by location and industry
Focus on the top 5 US companies that have laid off the most employees since 2022
Top 5 US companies’ stock performance since August 2022
Web scrapping for the current layoffs news from 3 different news websites
To perform this analysis, we will obtain the Layoffs dataset from Kaggle and the stock prices from Yahoo Finance. We will then analyze the dataset to see if there is any relationship between them.
Process Data
Tidy / Transform
Import those dataset into R
Tidy the data as necessary, eliminate unwanted columns
To combine the data sources, we need to link the top 5 US companies from layoffs dataset with stock historical data via YAHOO Finance
Analyze
US companies analysis by location and industry
Focus on the top 5 US companies that have laid off the most employees since 2022
Top 5 US companies’ stock performance since August 2022
Web scrapping for the current layoffs news from 3 different news websites
Present
The following libraries were used in this project:
library(readr)
library(tidyr)
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(stringr)
library(ggplot2)
library(rvest)
##
## Attaching package: 'rvest'
## The following object is masked from 'package:readr':
##
## guess_encoding
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ purrr 1.0.1
## ✔ lubridate 1.9.2 ✔ tibble 3.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ rvest::guess_encoding() masks readr::guess_encoding()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(reshape2)
##
## Attaching package: 'reshape2'
##
## The following object is masked from 'package:tidyr':
##
## smiths
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
##
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
##
## ######################### Warning from 'xts' package ##########################
## # #
## # The dplyr lag() function breaks how base R's lag() function is supposed to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
## # source() into this session won't work correctly. #
## # #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## # #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## ###############################################################################
##
## Attaching package: 'xts'
##
## The following objects are masked from 'package:dplyr':
##
## first, last
##
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(tidyquant)
## Loading required package: PerformanceAnalytics
##
## Attaching package: 'PerformanceAnalytics'
##
## The following object is masked from 'package:graphics':
##
## legend
library(tidytext)
library(wordcloud)
## Loading required package: RColorBrewer
##
## Attaching package: 'wordcloud'
##
## The following object is masked from 'package:PerformanceAnalytics':
##
## textplot
This dataset was made with the hope to enable Kaggle community to look into analyzing recent tech turmoil and discover useful insights.
# Load the Layoffs dataset into R
layoffs <-read_csv(file = '/Users/joycealdrich/Documents/SPS Data Science/Data 607/Final Project/layoffs.csv')
## Rows: 2438 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): company, location, industry, stage, country
## dbl (3): total_laid_off, percentage_laid_off, funds_raised
## date (1): date
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Examine the structure of the dataset
str(layoffs)
## spc_tbl_ [2,438 × 9] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ company : chr [1:2438] "CoverMyMeds" "Electronic Arts" "Shift" "Lucid Motors" ...
## $ location : chr [1:2438] "Columbus" "SF Bay Area" "SF Bay Area" "SF Bay Area" ...
## $ industry : chr [1:2438] "Healthcare" "Consumer" "Transportation" "Transportation" ...
## $ total_laid_off : num [1:2438] 800 780 NA 1300 119 46 275 170 NA 200 ...
## $ percentage_laid_off: num [1:2438] NA 0.06 0.3 0.18 NA 0.33 NA NA NA NA ...
## $ date : Date[1:2438], format: "2023-03-29" "2023-03-29" ...
## $ stage : chr [1:2438] "Acquired" "Post-IPO" "Post-IPO" "Post-IPO" ...
## $ country : chr [1:2438] "United States" "United States" "United States" "United States" ...
## $ funds_raised : num [1:2438] 5 2 504 8300 62 314 17 250 NA 500 ...
## - attr(*, "spec")=
## .. cols(
## .. company = col_character(),
## .. location = col_character(),
## .. industry = col_character(),
## .. total_laid_off = col_double(),
## .. percentage_laid_off = col_double(),
## .. date = col_date(format = ""),
## .. stage = col_character(),
## .. country = col_character(),
## .. funds_raised = col_double()
## .. )
## - attr(*, "problems")=<externalptr>
head(layoffs)
## # A tibble: 6 × 9
## company locat…¹ indus…² total…³ perce…⁴ date stage country funds…⁵
## <chr> <chr> <chr> <dbl> <dbl> <date> <chr> <chr> <dbl>
## 1 CoverMyMeds Columb… Health… 800 NA 2023-03-29 Acqu… United… 5
## 2 Electronic A… SF Bay… Consum… 780 0.06 2023-03-29 Post… United… 2
## 3 Shift SF Bay… Transp… NA 0.3 2023-03-29 Post… United… 504
## 4 Lucid Motors SF Bay… Transp… 1300 0.18 2023-03-28 Post… United… 8300
## 5 Blue Nile Seattle Retail 119 NA 2023-03-28 Acqu… United… 62
## 6 AEye SF Bay… Transp… 46 0.33 2023-03-28 Post… United… 314
## # … with abbreviated variable names ¹location, ²industry, ³total_laid_off,
## # ⁴percentage_laid_off, ⁵funds_raised
For this final project, the focus will be on US companies with a start date of January 1st, 2022
# filter US companies & drop unwanted variables
layoffs_1 <- layoffs %>%
subset(select =-c(percentage_laid_off, stage, funds_raised)) %>%
filter (country =="United States", total_laid_off !="" , date >="2022-01-01") %>%
arrange(company,date)
In this economic recession, there has been a significant impact on the US job market, with layoffs occurring in a wide range of locations and industries. The high number of layoffs in the San Francisco Bay Area, Seattle, and other major cities indicates that urban areas have been particularly affected. The dominance of tech-related industries such as consumer (Meta, Google, and others) and retail (Amazon and others) among the top industries also highlights the impact of automation and changing consumer behavior on the job market.
Over the last 6 months, we have often heard about these top 10 US cities in the news, especially regarding the layoffs in the tech-related industry in the San Francisco Bay Area, including companies like Google, Meta, Salesforce, Cisco, and others. Overall, these outcomes suggest the need for ongoing support and resources to help those affected by layoffs to find new employment opportunities and support the US economy during this challenging time.
# Count layoffs by location
layoffs_by_location <- layoffs_1%>%
group_by(location) %>%
summarize(total_layoffs = sum(total_laid_off))
# View the top 10 locations by layoffs
top_locations <- layoffs_by_location %>%
arrange(desc(total_layoffs)) %>%
head(10)
# Plot Top 10 locations by layoffs
ggplot(top_locations, aes(x = reorder(location, total_layoffs), y = total_layoffs)) +
geom_col(fill = "light blue") +
labs(title = "US Top 10 Locations by Layoffs 2022 - 2023", x = "Location", y = "Total Layoffs") +
geom_text(aes(label=total_layoffs),size =3, fontface = "bold")+
theme_bw() +
theme(axis.title.y = element_text(size = 12)) +
coord_flip()
# Count layoffs by industry
layoffs_by_industry <- layoffs_1 %>%
group_by(industry) %>%
summarize(total_layoffs = sum(total_laid_off))
# View the top 10 Industries by layoffs
top_industries <- layoffs_by_industry %>%
arrange(desc(total_layoffs)) %>%
head(10)
# Plot industries by layoffs
ggplot(top_industries, aes(x = reorder(industry, total_layoffs), y = total_layoffs)) +
geom_col(fill = "red") +
labs(title = "US Top 10 Industries by Layoffs 2022-2023", x = "Industry", y = "Total Layoffs") +
geom_text(aes(label=total_layoffs),size =3,
fontface = "bold")+
theme_bw() +
coord_flip()
The top 5 US companies that have laid off the most employees, will help to identify the companies that have been most affected by the economic slowdown and shed light on the factors that may have contributed to their layoffs.
Based on the latest analysis of the layoffs data for US companies, we found the following insights on the top 5 US companies:
Amazon: Since October 2022, Amazon has laid off a total of 27,150 employees over four rounds of layoffs. These layoffs were mainly related to the company’s efforts to streamline its operations and reduce costs.
Meta (formerly known as Facebook): Since November 2021, Meta has laid off a total of 21,000 employees over two rounds of layoffs. The most recent news indicates that Meta plans to lay off additional employees in the future, as part of its ongoing efforts to streamline its operations and focus on its core businesses.
Google: In this Janaury, Google has laid off a total of 12,000 employees.
Microsoft:In this Janaury, Microsoft has laid off a total of 10,000 employees.
Salesforce: Since October 2022, Salesforce has laid off a total of 1,090 employees.
# calculate total laid off
by_company <-layoffs_1 %>%
group_by(company) %>%
summarise(Total_count = sum(total_laid_off))
# get the top 5 companies data
top_5_companies <- by_company%>%
slice_max(Total_count, n=5)
# plot in to the chart
top_5_companies %>%
mutate(company = fct_reorder(company, Total_count)) %>%
ggplot( aes(x=Total_count,y=company, fill=company))+
geom_bar(stat='identity',width = 0.8) +
geom_text(aes(label=Total_count),size =3,
hjust = 1, nudge_x = -.5, fontface = "bold")+
theme_minimal()+
ggtitle("Layoffs Trend for Top 5 US Companies") +
labs(y="Companies", x="Layoff Count")
# get details of the top 5 companies
top_5_companies_details <-
filter (layoffs_1,company %in% top_5_companies$company)
top_5_companies_details
## # A tibble: 11 × 6
## company location industry total_laid_off date country
## <chr> <chr> <chr> <dbl> <date> <chr>
## 1 Amazon Seattle Retail 150 2022-10-28 United States
## 2 Amazon Seattle Retail 10000 2022-11-16 United States
## 3 Amazon Seattle Retail 8000 2023-01-04 United States
## 4 Amazon Seattle Retail 9000 2023-03-20 United States
## 5 Google SF Bay Area Consumer 12000 2023-01-20 United States
## 6 Meta SF Bay Area Consumer 11000 2022-11-09 United States
## 7 Meta SF Bay Area Consumer 10000 2023-03-14 United States
## 8 Microsoft Seattle Other 10000 2023-01-18 United States
## 9 Salesforce SF Bay Area Sales 90 2022-10-13 United States
## 10 Salesforce SF Bay Area Sales 1000 2022-11-07 United States
## 11 Salesforce SF Bay Area Sales 8000 2023-01-04 United States
Based on the laid off date, look into the top 5 US companies’ stock performance since August 2022 and to analyze the impact of stock price. The relationship between the layoff dates and the stock prices of these companies will also provide interesting insights into the impact of layoffs on their financial performance.
Per these top 5 companies’ stock price trend, it is notable that the stock price saw an upward trend after the company laid off employees overall these top 5 companies.
amazon_layoff<-
filter (layoffs_1, company %in% "Amazon")
meta_layoff<-
filter (layoffs_1, company %in% "Meta")
google_layoff<-
filter (layoffs_1, company %in% "Google")
microsoft_layoff<-
filter (layoffs_1, company %in% "Microsoft")
salesforce_layoff<-
filter (layoffs_1, company %in% "Salesforce")
# get amazon stock price
amazon <- tq_get('AMZN',
from = "2022-08-01",
get = "stock.prices")
# get meta stock price
meta <- tq_get('META',
from = "2022-08-01",
get = "stock.prices")
# get google stock price
google <- tq_get('GOOG',
from = "2022-08-01",
get = "stock.prices")
# get microsoft stock price
microsoft <- tq_get('MSFT',
from = "2022-08-01",
get = "stock.prices")
# get salesforce stock price
salesforce <- tq_get('CRM',
from = "2022-08-01",
get = "stock.prices")
# Plot the data using ggplot and geom_line
amazon %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line() +
theme_classic()+
# Add vertical lines using the date variable in the amazom layoff dataframe
geom_vline(data=amazon_layoff, aes(xintercept =date), linetype = "dashed", color = "blue") +
ggtitle("Amazon Stock Price 2022-2023 vs Layoffs") +
labs(y="Stock Price", x="Date (August 2022 to April 2023)")
meta %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line() +
theme_classic()+
geom_vline(data=meta_layoff, aes(xintercept =date), linetype = "dashed", color = "blue") +
ggtitle("Meta Stock Price 2022-2023 vs Layoffs") +
labs(y="Stock Price", x="Date (August 2022 to April 2023)")
google %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line() +
geom_vline(data=google_layoff, aes(xintercept =date), linetype = "dashed", color = "blue") +
ggtitle("Google Stock Price 2022-2023 vs Layoffs") +
labs(y="Stock Price", x="Date (August 2022 to April 2023)")
microsoft %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line() +
geom_vline(data=microsoft_layoff, aes(xintercept =date), linetype = "dashed", color = "blue") +
ggtitle("Microsoft Stock Price 2022-2023 vs Layoffs") +
labs(y="Stock Price", x="Date (August 2022 to April 2023)")
salesforce %>%
ggplot(aes(x = date, y = adjusted, color = symbol)) +
geom_line() +
geom_vline(data=salesforce_layoff, aes(xintercept =date), linetype = "dashed", color = "blue") +
ggtitle("Salesforce Stock Price 2022-2023 vs Layoffs") +
labs(y="Stock Price", x="Date (August 2022 to April 2023)")
Note that “Meta” is the most frequent word in this word cloud, created from headlines across three different sources filtered by the keyword “layoffs”. This suggests that the layoffs at Meta, previously known as Facebook, have garnered significant attention in the media. It’s worth noting that both Meta and Amazon have been impacted by the recent economic downturn, and have been actively seeking solutions to improve their companies’ financial outlook for their investors. Despite these efforts, both companies have seen multiple rounds of layoffs, indicating that layoffs may not be enough to mitigate the economic impact. This trend may continue and may result in another company taking the lead in the US market, potentially leading to a shift in the other industries.
Obtain news headlines via 3 different news sites, WSJ, Business insider, and TechCrunch and searching “layoffs” keyword.
library(rvest)
library(dplyr)
link_1 = "https://www.wsj.com/search?query=layoffs&mod=searchresults_viewallresults"
news_1 = read_html(link_1)
headlines_1 = news_1 %>%
html_nodes("div:nth-child(5) .WSJTheme--headlineText--He1ANr9C") %>%
html_text()
link_2 = "https://www.businessinsider.com/s?q=layoffs"
news_2 = read_html(link_2)
headlines_2 = news_2 %>%
html_nodes(".tout-title-link") %>%
html_text()
link_3 = "https://search.techcrunch.com/search;_ylc=X3IDMgRncHJpZANsLjlMRmdMblFlQ3BsNlJRQUpqaHNBBG5fc3VnZwM5BHBvcwMwBHBxc3RyAwRwcXN0cmwDMARxc3RybAM3BHF1ZXJ5A2xheW9mZnMEdF9zdG1wAzE2ODIwOTI1MTA-?p=layoffs&fr=techcrunch"
news_3 = read_html(link_3)
headlines_3 = news_3 %>%
html_nodes(".fw-b") %>%
html_text()
headlines_1
## [1] "Meta Will Slow Hiring, Won’t Rule Out Future Layoffs"
## [2] "Lyft to Cut at Least 1,200 Jobs in New Round of Layoffs"
## [3] "The Companies Conducting Layoffs in 2023: Here’s the List"
## [4] "Lyft Stock Spikes After Report of Layoffs"
## [5] "AT&T Sees Signs of Businesses, Consumers Paring Back Spending"
## [6] "Fed Rethinks Loophole That Masked Losses on SVB’s Securities"
## [7] "Stocks to Watch Friday: Meta, Tesla, Procter & Gamble"
## [8] "Whole Foods Plans Corporate Job Cuts, Shuffles Structure"
## [9] "New Normal for PCs Looks Worse Than the Old One"
## [10] "Laid-Off Tech Workers Launch ‘Revenge Startups’ Just as Money Dries Up"
## [11] "Supplier Prices Fell in March"
## [12] "McDonald’s Cuts Pay Packages, Closes Offices Alongside Layoffs"
## [13] "AT&T Stock Sinks, Set For One of Worst Days on Record"
## [14] "Facebook Parent Meta Plans 10,000 Job Cuts in New Round of Layoffs"
## [15] "Goldman Cut 6% of Staff in the First Quarter, BofA Says Job Cuts Are Coming"
## [16] "AT&T, Netflix, BuzzFeed: Stocks That Defined the Week"
## [17] "BuzzFeed News Is Shutting Down, and Vice World News Could Be Next"
## [18] "Staffing Levels Dropped at Several Big Banks"
## [19] "Stocks Close Higher After Jobless Claims"
## [20] "Amazon to Cut 9,000 More Jobs After Earlier Layoffs"
headlines_2
## [1] "Leaked memo reveals Disney's new finance structure as more layoffs loom, with a reported 15% of entertainment staffers to be cut"
## [2] "Mark Zuckerberg isn't ruling out future layoffs at Meta 'given the volatility,' a report says"
## [3] "Meta's latest layoffs: Here are more than a dozen jobs and teams hit most by this week's cuts"
## [4] "Meta employees criticize Mark Zuckerberg's second round of layoffs in an internal forum: 'you've shattered the morale and confidence in leadership,' report says"
## [5] "We mapped out the 113 most powerful people at Warner Bros. Discovery after a blockbuster merger and a tumultuous year of layoffs and cuts under CEO David Zaslav"
## [6] "Meta's latest round of layoffs will hurt productivity and damage employee morale"
## [7] "Meta is ramping up its investment in gaming projects even as layoffs hit the rest of the company"
## [8] "Facebook’s parent company Meta is doing layoffs again. But there’s one ‘safe’ team that could actually benefit from the job cuts."
## [9] "I'm a former Microsoft VP of HR. Here are the real reasons why layoffs are happening and how much longer they'll last."
## [10] "Meta's layoffs are affecting customer service and leaving influencers and businesses on Instagram and Facebook in the lurch, report says"
## [11] "How David Zaslav is transforming Warner Bros. Discovery, from layoffs and a major reorg to launching a new mega-streaming app, Max"
## [12] "Companies can't do layoffs right because they're trying to act like 'cool parents'"
## [13] "More layoffs may still come for tech workers"
## [14] "Softbank-backed adtech firm Permutive announces further layoffs, which could affect up to 40% of staff"
## [15] "Amazon salaries revealed: Here's how much engineers, data scientists, and thousands of other employees were paid before recent layoffs"
## [16] "CHART: We analyzed Apple's revenue per employee to show how it's avoided tech bloat and delayed layoffs"
## [17] "ABC News layoffs left insiders 'outraged' by how veteran execs' exits were handled"
## [18] "How tech layoffs could affect the economy"
## [19] "Read the full memo: McDonald's outlines plans for layoffs and shift in strategy"
## [20] "Tesla rival Lucid plans layoffs, as manufacturing and production challenges mount for EV startups"
headlines_3
## [1] "Elon Musk's Twitter: Everything you need to know, from layoffs to verification"
## [2] "A comprehensive list of 2023 tech layoffs"
## [3] "Meta can be sued in Kenya over alleged unlawful layoffs and blacklisting of moderators, court rules"
## [4] "Another round of mass layoffs expected at Meta this week"
## [5] "Lyft hails new leadership, layoffs come for Lucid, and Waymo retires its self-driving minivan"
## [6] "Roku announces a second set of layoffs impacting 200 employees, or 6% of its workforce"
## [7] "The first round of Disney layoffs begins this week, CEO Bob Iger shares in memo"
## [8] "The layoffs will continue until (investor) morale improves"
## [9] "Roofstock, valued at $1.9B last year, cuts 27% of staff in second round of layoffs"
## [10] "AWS takes a hit in latest round of Amazon layoffs"
# Combine the headlines from three pages
all_headlines <- c(headlines_1, headlines_2, headlines_3)
# Create a data frame with one column for the text
df <- data.frame(text = all_headlines)
# Tokenize the text and remove unwanted word
tokens <- df %>%
unnest_tokens(word, text) %>%
anti_join(stop_words) %>%
filter(!word %in% c("layoffs")) %>%
mutate(word = gsub("'s$", "", word))
## Joining with `by = join_by(word)`
# Create a frequency table of the words
word_freq <- tokens %>%
count(word, sort = TRUE)
# Create a word cloud
wordcloud(word_freq$word, word_freq$n, max.words = 50, colors = brewer.pal(8, "Dark2"))
I focused on analyzing the top 5 US companies that have laid off the most employees since 2022, using their stock price data from August 2022. To conduct the analysis, I used the layoff dataset from Kaggle and historical stock price data.
Based on the analysis, it was found that San Francisco Bay Area had the highest number of layoffs compared to other metropolitan cities. Additionally, most of the laid off companies belonged to the tech industry and were classified under the consumer industry. Amazon and Meta were the two most affected companies since last October, and they had to undergo multiple rounds of layoffs, indicating that layoffs alone may not be sufficient to mitigate the economic impact. This trend is likely to continue, and it may lead to another company taking the lead in the US market, potentially resulting in a shift in other industries.