R Markdown
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Loading data
data <- read_csv("https://query1.finance.yahoo.com/v7/finance/download/MSFT?period1=511108200&period2=1707781895&interval=1wk&events=history&includeAdjustedClose=true")
## Rows: 1980 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (6): Open, High, Low, Close, Adj Close, Volume
## 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.
- 1980
Renaming a variable
new_data <- rename(data, MSFT=`Adj Close`)
Plotting a line graph
graph <- ggplot(data=new_data, aes(x=Date, y=MSFT)) + geom_line()
graph + ggtitle("Microsoft Adj Close Prices Overtime")

- The graph shows the change in trends of Microsoft closing prices
over a period of time between March 13th 1986 to now. The Adj Close
price which is represented in my graph by “MSFT” is the closing price of
the Microsoft Stock each week. As seen, the closing price of stock
significantly increases between the years of 2010 and 2020. The stock
price had a slight increase around year 2000 but a major spike in recent
years. The Adj close price started under 20 dollars while is now more
than 400.