Skip to content

Instantly share code, notes, and snippets.

@Chhunneng
Created December 15, 2021 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chhunneng/2345fcf5c2b36f8f3738acbb009aa24d to your computer and use it in GitHub Desktop.
Save Chhunneng/2345fcf5c2b36f8f3738acbb009aa24d to your computer and use it in GitHub Desktop.
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