library(quantmod)
## Loading required package: xts
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.4.3
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
getSymbols("MSFT", src="yahoo",from = "2025-10-01", to = "2026-02-01")
## [1] "MSFT"
nrow(MSFT)
## [1] 84
colnames(MSFT)
## [1] "MSFT.Open" "MSFT.High" "MSFT.Low" "MSFT.Close"
## [5] "MSFT.Volume" "MSFT.Adjusted"
# Find the row index of the highest Open price
max_index <- which.max(MSFT$MSFT.Open)
# Get the date and value
max_date <- index(MSFT)[max_index] # index() gives the dates
max_value <- MSFT$MSFT.Open[max_index]
max_date
## [1] "2025-10-28"
max_value
## MSFT.Open
## 2025-10-28 550