{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE)

Install packages

{r} install.packages("quantmod")

Load package

{r} library(quantmod)

Get symbols

{r} getSymbols(c("MSFT", "BAC", "HOOD", "TSLA"), src="yahoo")

Msft stock prices in given period

{r} getSymbols("MSFT", src="yahoo",from = "2024-10-01", to = "2025-02-01")

View of first few rows

{r} head(MSFT)

Show open prices

{r} open_prices <- MSFT$MSFT.Open

Find date with highest open price

{r} which.max(open_prices) open_prices[which.max(open_prices)]

Quick line plot of open prices

{r} plot(open_prices, main = "Microsoft Open Prices", col = "blue")