Created
December 15, 2021 18:01
-
-
Save Chhunneng/2345fcf5c2b36f8f3738acbb009aa24d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(quantmod) | |
library(ggplot2) | |
library(magrittr) # for %>% function | |
library(broom) # tidy function | |
start = as.Date("2021-01-01") | |
end = as.Date("2021-12-01") | |
getSymbols("GOOGL", src = "yahoo", from = start, to = end) | |
write.zoo(GOOGL, "GOOGL.csv", sep = ",") | |
stocks = as.xts(data.frame(A = GOOGL[, "GOOGL.Adjusted"])) | |
stocks_series = tidy(stocks) %>% | |
ggplot(aes(x=index,y=value)) + | |
labs( | |
subtitle = "End of Day Adjusted Prices", | |
caption = "Midterm Exam" | |
) + | |
ggtitle("Google Stock Price") + theme( | |
plot.title = element_text(hjust = 0.5, size = 20) | |
) + | |
xlab("Date") + ylab("Price") + geom_line() | |
stocks_series |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment