Run install packages
#install.packages("quantmod")
load / activate the package
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
##
## 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
Load data
getSymbols(c("AMZN"), src = "yahoo")
## [1] "AMZN"
Returning exact stock prices
getSymbols("MSFT", src="yahoo",from = "2025-10-01", to = "2026-01-31")
## [1] "MSFT"
How many days of stock prices returned
nrow(MSFT)
## [1] 84
When was the highest open price
plot(Op(MSFT),
main = "MSFT Open Prices (Oct 2025 - Jan 2026)",
ylab = "Open Price",
xlab = "Date")
Extracting data
#CRAN version
#install.packages("baseballr")
#if (!requireNamespace('devtools', quietly = TRUE)){
# install.packages('devtools')
#}
#devtools::install_github(repo = "BillPetti/baseballr")
library(baseballr)
library(dplyr)
##
## ######################### Warning from 'xts' package ##########################
## # #
## # The dplyr lag() function breaks how base R's lag() function is supposed to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
## # source() into this session won't work correctly. #
## # #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## # #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## ###############################################################################
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:xts':
##
## first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
cal_raleigh <- mlb_people(person_id = 663728)