R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ ggplot2 3.3.5     ✓ purrr   0.3.4
## ✓ tibble  3.1.5     ✓ dplyr   1.0.7
## ✓ tidyr   1.1.4     ✓ stringr 1.4.0
## ✓ readr   2.0.2     ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter()         masks stats::filter()
## x readr::guess_encoding() masks rvest::guess_encoding()
## x dplyr::lag()            masks stats::lag()
## Loading required package: lubridate
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
## Loading required package: PerformanceAnalytics
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
## 
##     legend
## Loading required package: quantmod
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
## ══ Need to Learn tidyquant? ════════════════════════════════════════════════════
## Business Science offers a 1-hour course - Learning Lab #9: Performance Analysis & Portfolio Optimization with tidyquant!
## </> Learn more at: https://university.business-science.io/p/learning-labs-pro </>
## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
## 
## Attaching package: 'dbplyr'
## The following objects are masked from 'package:dplyr':
## 
##     ident, sql
## [1] "2021-10-09"
## # A tibble: 6 × 8
##   symbol date        open  high   low close     volume adjusted
##   <chr>  <date>     <dbl> <dbl> <dbl> <dbl>      <dbl>    <dbl>
## 1 ^GSPC  2021-10-11 4385. 4416. 4361. 4361. 2580000000    4361.
## 2 ^GSPC  2021-10-12 4368. 4375. 4342. 4351. 2608150000    4351.
## 3 ^GSPC  2021-10-13 4358. 4373. 4330. 4364. 2926460000    4364.
## 4 ^GSPC  2021-10-14 4387. 4440. 4387. 4438. 2642920000    4438.
## 5 ^GSPC  2021-10-15 4448. 4476. 4448. 4471. 3000560000    4471.
## 6 ^GSPC  2021-10-18 4464. 4489. 4447. 4486. 2683540000    4486.
## # A tibble: 1 × 1
##   `Total Number of Tickers`
##                       <int>
## 1                       505
## # A tibble: 6 × 16
##   symbol date        open  high   low close  volume adjusted security sec_filings
##   <chr>  <date>     <dbl> <dbl> <dbl> <dbl>   <dbl>    <dbl> <chr>    <chr>      
## 1 MMM    2021-10-11  178.  179.  176.  176. 2691100     175. 3M       reports    
## 2 MMM    2021-10-12  176.  177.  175.  176. 2155900     174. 3M       reports    
## 3 MMM    2021-10-13  176.  178.  175.  177. 2030500     176. 3M       reports    
## 4 MMM    2021-10-14  178   180.  178.  180. 2279200     179. 3M       reports    
## 5 MMM    2021-10-15  181.  183   181.  182. 2160800     180. 3M       reports    
## 6 MMM    2021-10-18  181.  182.  179.  182. 1753300     180. 3M       reports    
## # … with 6 more variables: gics_sector <chr>, gics_sub_industry <chr>,
## #   headquarters_location <chr>, date_first_added <chr>, cik <int>,
## #   founded <chr>

## `summarise()` has grouped output by 'security', 'gics_sector'. You can override using the `.groups` argument.
## # A tibble: 6 × 5
## # Groups:   security, gics_sector [6]
##   security        gics_sector            symbol avg_return Volatility
##   <chr>           <chr>                  <chr>       <dbl>      <dbl>
## 1 Ford            Consumer Discretionary F          0.0082     0.0312
## 2 Teradyne        Information Technology TER        0.0064     0.0246
## 3 Qualcomm        Information Technology QCOM       0.0062     0.0264
## 4 Dollar Tree     Consumer Discretionary DLTR       0.006      0.0257
## 5 HP              Information Technology HPQ        0.0057     0.0222
## 6 Arista Networks Information Technology ANET       0.0055     0.0330

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.