Skip to content

Commit 1c2751e

Browse files
authored
Week 6. (#510)
1 parent 8a6812e commit 1c2751e

File tree

8 files changed

+45293
-0
lines changed

8 files changed

+45293
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ Need a **reminder**? There are [extensions](https://chrome.google.com/webstore/d
127127
| 3 | `2023-01-17` | [Art history data](data/2023/2023-01-17/readme.md) | [arthistory data package](https://saralemus7.github.io/arthistory/) | [Quantifying Art Historical Narratives](https://github.com/hollandstam1/thesis/blob/main/_book/Quantifying-Art-Historical-Narratives.pdf) |
128128
| 4 | `2023-01-24` | [Alone data](data/2023/2023-01-24/readme.md) | [Alone data package](https://github.com/doehm/alone) | [Alone R package: Datasets from the survival TV series](https://gradientdescending.com/alone-r-package-datasets-from-the-survival-tv-series/) |
129129
| 5 | `2023-01-31` | [Pet Cats UK](data/2023/2023-01-31/readme.md) | [Movebank for Animal Tracking Data](https://www.datarepository.movebank.org/handle/10255/move.882) | [Cats on the Move](https://themarkup.org/data-is-plural/2023/01/25/from-jazz-solos-to-cats-on-the-move#:~:text=Giuseppe%20Sollazzo%5D-,Cats%20on%20the%20move,-.%20Between%202013) |
130+
| 6 | `2023-02-07` | [Big Tech Stock Prices](data/2023/2023-02-07/readme.md) | [Big Tech Stock Prices on Kaggle](https://www.kaggle.com/datasets/evangower/big-tech-stock-prices) | [5 Charts on Big Tech Stocks’ Collapse](https://www.morningstar.com/articles/1129535/5-charts-on-big-tech-stocks-collapse) |
130131

131132
***
132133

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
stock_symbol,company
2+
AAPL,Apple Inc.
3+
ADBE,Adobe Inc.
4+
AMZN,"Amazon.com, Inc."
5+
CRM,"Salesforce, Inc."
6+
CSCO,"Cisco Systems, Inc."
7+
GOOGL,Alphabet Inc.
8+
IBM,International Business Machines Corporation
9+
INTC,Intel Corporation
10+
META,"Meta Platforms, Inc."
11+
MSFT,Microsoft Corporation
12+
NFLX,"Netflix, Inc."
13+
NVDA,NVIDIA Corporation
14+
ORCL,Oracle Corporation
15+
TSLA,"Tesla, Inc."

data/2023/2023-02-07/big_tech_stock_prices.csv

Lines changed: 45089 additions & 0 deletions
Large diffs are not rendered by default.

data/2023/2023-02-07/pic1.png

40.6 KB
Loading

data/2023/2023-02-07/pic2.png

45.3 KB
Loading
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"article_link": "https://www.morningstar.com/articles/1129535/5-charts-on-big-tech-stocks-collapse",
3+
"pic1_alt": "A bar chart showing percent returns for Apple, Microsoft, Alphabet, Nvidia, Amazon.com, and Meta Platforms, for 2021 (green, positive bars) and 2022 (red, negative bars).",
4+
"pic2_alt": "A table of percent returns for Apple, Microsoft, Alphabet, Nvidia, Amazon.com, and Meta Platforms, with columns for YTD (as of December 9, 2022), since last peak, 3 years, and 5 years. YTD and since last peak are all negative. 3-year and 5-year are all at least slightly positive, except Meta which is negative for both."
5+
}

data/2023/2023-02-07/readme.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
### Please add alt text to your posts
2+
3+
Please add alt text (alternative text) to all of your posted graphics for `#TidyTuesday`.
4+
5+
Twitter provides [guidelines](https://help.twitter.com/en/using-twitter/picture-descriptions) for how to add alt text to your images.
6+
7+
The DataViz Society/Nightingale by way of Amy Cesal has an [article](https://medium.com/nightingale/writing-alt-text-for-data-visualization-2a218ef43f81) on writing _good_ alt text for plots/graphs.
8+
9+
> Here’s a simple formula for writing alt text for data visualization:
10+
> ### Chart type
11+
> It’s helpful for people with partial sight to know what chart type it is and gives context for understanding the rest of the visual.
12+
> Example: Line graph
13+
> ### Type of data
14+
> What data is included in the chart? The x and y axis labels may help you figure this out.
15+
> Example: number of bananas sold per day in the last year
16+
> ### Reason for including the chart
17+
> Think about why you’re including this visual. What does it show that’s meaningful. There should be a point to every visual and you should tell people what to look for.
18+
> Example: the winter months have more banana sales
19+
> ### Link to data or source
20+
> Don’t include this in your alt text, but it should be included somewhere in the surrounding text. People should be able to click on a link to view the source data or dig further into the visual. This provides transparency about your source and lets people explore the data.
21+
> Example: Data from the USDA
22+
23+
Penn State has an [article](https://accessibility.psu.edu/images/charts/) on writing alt text descriptions for charts and tables.
24+
25+
> Charts, graphs and maps use visuals to convey complex images to users. But since they are images, these media provide serious accessibility issues to colorblind users and users of screen readers. See the [examples on this page](https://accessibility.psu.edu/images/charts/) for details on how to make charts more accessible.
26+
27+
The `{rtweet}` package includes the [ability to post tweets](https://docs.ropensci.org/rtweet/reference/post_tweet.html) with alt text programatically.
28+
29+
Need a **reminder**? There are [extensions](https://chrome.google.com/webstore/detail/twitter-required-alt-text/fpjlpckbikddocimpfcgaldjghimjiik/related) that force you to remember to add Alt Text to Tweets with media.
30+
31+
# Big Tech Stock Prices
32+
33+
The data this week comes from Yahoo Finance via [Kaggle](https://www.kaggle.com/datasets/evangower/big-tech-stock-prices) (by [Evan Gower](https://github.com/rfordatascience/tidytuesday/issues/509)).
34+
35+
> This dataset consists of the daily stock prices and volume of 14 different tech companies, including Apple (AAPL), Amazon (AMZN), Alphabet (GOOGL), and Meta Platforms (META) and more!
36+
37+
A number of articles have examined the collapse of "Big Tech" stock prices, including [this article from morningstar.com](https://www.morningstar.com/articles/1129535/5-charts-on-big-tech-stocks-collapse).
38+
39+
Note: All `stock_symbol`s have 3271 prices, except META (2688) and TSLA (3148) because they were not publicly traded for part of the period examined.
40+
41+
### Get the data here
42+
43+
```{r}
44+
# Get the Data
45+
46+
# Read in with tidytuesdayR package
47+
# Install from CRAN via: install.packages("tidytuesdayR")
48+
# This loads the readme and all the datasets for the week of interest
49+
50+
# Either ISO-8601 date or year/week works!
51+
52+
tuesdata <- tidytuesdayR::tt_load('2023-02-07')
53+
tuesdata <- tidytuesdayR::tt_load(2023, week = 6)
54+
55+
big_tech_stock_prices <- tuesdata$big_tech_stock_prices
56+
big_tech_companies <- tuesdata$big_tech_companies
57+
58+
# Or read in the data manually
59+
60+
big_tech_stock_prices <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-02-07/big_tech_stock_prices.csv')
61+
big_tech_companies <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-02-07/big_tech_companies.csv')
62+
```
63+
64+
### Data Dictionary
65+
66+
# `big_tech_stock_prices.csv`
67+
68+
|variable |class |description |
69+
|:------------|:---------|:------------|
70+
|stock_symbol |character |stock_symbol |
71+
|date |double |date |
72+
|open |double |The price at market open.|
73+
|high |double |The highest price for that day.|
74+
|low |double |The lowest price for that day.|
75+
|close |double |The price at market close, adjusted for splits.|
76+
|adj_close |double |The closing price after adjustments for all applicable splits and dividend distributions. Data is adjusted using appropriate split and dividend multipliers, adhering to Center for Research in Security Prices (CRSP) standards.|
77+
|volume |double |The number of shares traded on that day.|
78+
79+
# `big_tech_companies.csv`
80+
81+
|variable |class |description |
82+
|:------------|:---------|:------------|
83+
|stock_symbol |character |stock_symbol |
84+
|company |character |Full name of the company.|
85+
86+
87+
### Cleaning Script
88+
89+
```r
90+
library(fs)
91+
library(tidyverse)
92+
library(here)
93+
library(janitor)
94+
95+
# Source for datasets. The datasets were downloaded and extracted to an
96+
# "archive" folder within the working directory for processing, but they are not
97+
# included in this repo.
98+
"https://www.kaggle.com/datasets/evangower/big-tech-stock-prices"
99+
100+
# This is mostly equivalent to fs::dir_map, but we need to keep the info from
101+
# the filename.
102+
big_tech_stock_prices_list <- purrr::map(
103+
fs::dir_ls(
104+
here::here("data", "2023", "2023-02-07", "archive"),
105+
glob = "*.csv"
106+
),
107+
\(path) {
108+
ticker <- fs::path_file(path) |> fs::path_ext_remove()
109+
readr::read_csv(
110+
file = path,
111+
col_types = cols(
112+
Date = col_date(format = ""),
113+
Open = col_double(),
114+
High = col_double(),
115+
Low = col_double(),
116+
Close = col_double(),
117+
`Adj Close` = col_double(),
118+
Volume = col_double()
119+
)
120+
) |>
121+
dplyr::mutate(stock_symbol = ticker, .before = 1)
122+
}
123+
)
124+
125+
big_tech_stock_prices <- purrr::list_rbind(big_tech_stock_prices_list) |>
126+
janitor::clean_names()
127+
dplyr::glimpse(big_tech_stock_prices)
128+
129+
readr::write_csv(
130+
big_tech_stock_prices,
131+
here::here(
132+
"data", "2023", "2023-02-07",
133+
"big_tech_stock_prices.csv"
134+
)
135+
)
136+
137+
big_tech_stock_prices |>
138+
dplyr::count(stock_symbol, sort = TRUE)
139+
140+
141+
# Make a lookup for the symbols.
142+
tibble::tibble(
143+
stock_symbol = c(
144+
"AAPL",
145+
"ADBE",
146+
"AMZN",
147+
"CRM",
148+
"CSCO",
149+
"GOOGL",
150+
"IBM",
151+
"INTC",
152+
"META",
153+
"MSFT",
154+
"NFLX",
155+
"NVDA",
156+
"ORCL",
157+
"TSLA"
158+
),
159+
company = c(
160+
"Apple Inc.",
161+
"Adobe Inc.",
162+
"Amazon.com, Inc.",
163+
"Salesforce, Inc.",
164+
"Cisco Systems, Inc.",
165+
"Alphabet Inc.",
166+
"International Business Machines Corporation",
167+
"Intel Corporation",
168+
"Meta Platforms, Inc.",
169+
"Microsoft Corporation",
170+
"Netflix, Inc.",
171+
"NVIDIA Corporation",
172+
"Oracle Corporation",
173+
"Tesla, Inc."
174+
)
175+
) |>
176+
readr::write_csv(
177+
here::here(
178+
"data", "2023", "2023-02-07",
179+
"big_tech_companies.csv"
180+
)
181+
)
182+
```

data/2023/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Archive of datasets and articles from the 2023 series of `#TidyTuesday` events.
99
| 3 | `2023-01-17` | [Art history data](2023-01-17/readme.md) | [arthistory data package](https://saralemus7.github.io/arthistory/) | [Quantifying Art Historical Narratives](https://github.com/hollandstam1/thesis/blob/main/_book/Quantifying-Art-Historical-Narratives.pdf) |
1010
| 4 | `2023-01-24` | [Alone data](2023-01-24/readme.md) | [Alone data package](https://github.com/doehm/alone) | [Alone R package: Datasets from the survival TV series](https://gradientdescending.com/alone-r-package-datasets-from-the-survival-tv-series/) |
1111
| 5 | `2023-01-31` | [Pet Cats UK](2023-01-31/readme.md) | [Movebank for Animal Tracking Data](https://www.datarepository.movebank.org/handle/10255/move.882) | [Cats on the Move](https://themarkup.org/data-is-plural/2023/01/25/from-jazz-solos-to-cats-on-the-move#:~:text=Giuseppe%20Sollazzo%5D-,Cats%20on%20the%20move,-.%20Between%202013) |
12+
| 6 | `2023-02-07` | [Big Tech Stock Prices](2023-02-07/readme.md) | [Big Tech Stock Prices on Kaggle](https://www.kaggle.com/datasets/evangower/big-tech-stock-prices) | [5 Charts on Big Tech Stocks’ Collapse](https://www.morningstar.com/articles/1129535/5-charts-on-big-tech-stocks-collapse) |

0 commit comments

Comments
 (0)