library(ggplot2) library(scales) library(dplyr) data(“economics”) economics %>% head()

ggplot(data = economics, mapping = aes(x = date, y = psavert)) + geom_line() + labs(title = “Personal Savings Rate”, x = “Date”, y = “Personal Savings Rate”)

ggplot(data = economics, mapping = aes(x = date, y = psavert)) + geom_line(color = “indianred3”, size = 1) + geom_smooth() + scale_x_date(date_breaks = “5 years”, labels = date_format(“%b-%y”)) + labs(title = “Personal Savings Rate”, subtitle = “From 1967 to 2015”, x = ““, y =”Personal Savings Rate”) + theme_minimal()

apple <- getSymbols(“AAPL”, return.class = “data.frame”, from = “2021-05-05”) apple <- AAPL %>% mutate(Date = as.Date(row.names(.))) %>% select(Date, AAPL.Close) %>% rename(Close = AAPL.Close) %>% mutate(Company = “Apple”) # Take data for Facebook facebook <- getSymbols(“FB”, return.class = “data.frame”, from = “2021-05-05”) facebook <- FB %>% mutate(Date = as.Date(row.names(.))) %>% select(Date, FB.Close) %>% rename(Close = FB.Close) %>%

library(quantmod) ###################################################################### mutate(Company = “Facebook”) # Combine data data_series <- rbind(apple, facebook) # Visualization # National Association of Securities Dealers Automated Quotation System ggplot(data = data_series, mapping = aes(x = Date, y = Close, color = Company)) + geom_line(size = 1) + scale_x_date(date_breaks = “1 month”, label = date_format(“%b-%Y”)) + theme(axis.text.x = element_text(angle = 45, hjust = 1)) + scale_y_continuous(limits = c(100, 450), breaks = seq(100,400,50), labels = dollar) + labs(title = “NASDAQ Closing Prices”, subtitle = “From May 2021 to February 2022”, caption = “source: Yahoo Finance”, x = ““, y =”Closing Price”) + scale_color_brewer(palette = “Set1”)