Use the given code below to answer the questions.

## Load package
library(tidyverse) # for cleaning, plotting, etc
## ── Attaching packages ───────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.2.1     ✓ purrr   0.3.3
## ✓ tibble  2.1.3     ✓ dplyr   0.8.3
## ✓ tidyr   1.0.2     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ forcats 0.4.0
## ── Conflicts ──────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(tidyquant) # for financial analysis
## Loading required package: lubridate
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
## 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
## Version 0.4-0 included new data defaults. See ?getSymbols.
## ══ 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 </>
## Import data
stocks <- tq_get("WMT", get = "stock.prices", from = "2016-01-01")
stocks
## # A tibble: 1,033 x 7
##    date        open  high   low close   volume adjusted
##    <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 2016-01-04  60.5  61.5  60.4  61.5 11989200     55.7
##  2 2016-01-05  62.0  63.0  61.8  62.9 13326000     57.1
##  3 2016-01-06  62.5  64.0  62.5  63.5 16564600     57.6
##  4 2016-01-07  63.0  65.2  62.9  65.0 26430000     59.0
##  5 2016-01-08  65.1  65.4  63.4  63.5 17767900     57.6
##  6 2016-01-11  63.8  64.5  63.6  64.2 12653800     58.2
##  7 2016-01-12  64.4  64.7  63.4  63.6 12195900     57.7
##  8 2016-01-13  63.7  63.7  61.8  61.9 13725700     56.2
##  9 2016-01-14  62    63.6  61.8  63.1 12934900     57.2
## 10 2016-01-15  61.5  62.5  61.3  61.9 15174400     56.2
## # … with 1,023 more rows
## Visualize
stocks %>%
  ggplot(aes(x = date, y = close)) +
  geom_line()

Q1 Get Walmart stock prices, instead of Apple.

Hint: Insert a new code chunk below and type in the code, using the tq_get() function above. Replace the ticker symbol for Walmart. You may find the ticker symbol for Microsoft from Yahoo Finance.

## Load package
library(tidyverse) # for cleaning, plotting, etc
library(tidyquant) # for financial analysis

## Import data
stocks <- tq_get("WMT", get = "stock.prices", from = "2016-01-01")
stocks
## # A tibble: 1,033 x 7
##    date        open  high   low close   volume adjusted
##    <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 2016-01-04  60.5  61.5  60.4  61.5 11989200     55.7
##  2 2016-01-05  62.0  63.0  61.8  62.9 13326000     57.1
##  3 2016-01-06  62.5  64.0  62.5  63.5 16564600     57.6
##  4 2016-01-07  63.0  65.2  62.9  65.0 26430000     59.0
##  5 2016-01-08  65.1  65.4  63.4  63.5 17767900     57.6
##  6 2016-01-11  63.8  64.5  63.6  64.2 12653800     58.2
##  7 2016-01-12  64.4  64.7  63.4  63.6 12195900     57.7
##  8 2016-01-13  63.7  63.7  61.8  61.9 13725700     56.2
##  9 2016-01-14  62    63.6  61.8  63.1 12934900     57.2
## 10 2016-01-15  61.5  62.5  61.3  61.9 15174400     56.2
## # … with 1,023 more rows

Q2 How many columns (variables) are there?

7 columns

Q3 Interpret the second observation?

It went from 62 to 63

Q4 What type of data are they? What are other basic data types in R?

Hint: Watch the video, “Basic Data Types”, in DataCamp: Introduction to R for Finance: Ch1 The Basics.

The data is numeric

Q5 Plot the adjusted closing price in a line chart.

Hint: Insert a new code chunk below and type in the code, using the ggplot() function above. Revise the code so that it maps adjusted to the y-axis, instead of close.

For more information on the ggplot() function, refer to Ch2 Introduction to ggplot2 in one of our e-textbooks, Data Visualization with R.

Q6 From the chart you created in Q5, briefly describe how the Amazon stock has performed since the beginning of 2019.

Q7 Hide the messages and the code, but display results of the code from the webpage.

Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.

Q8 Hide the given code at the top and its results from the webpage.

Hint: Use eval in the chunk option. Refer to the RMarkdown Reference Guide.

Q9 Display the title and your name correctly at the top of the webpage.

Q10 Use the correct slug.