Use the given code below to answer the questions.

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

## Import data
stocks <- tq_get("AAPL", get = "stock.prices", from = "2016-01-01")
stocks

## 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("NKE", get = "stock.prices", from = "2016-01-01")
stocks
## # A tibble: 1,028 x 7
##    date        open  high   low close   volume adjusted
##    <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 2016-01-04  61.1  61.9  60.9  61.5 11626800     58.5
##  2 2016-01-05  61.7  62.6  61.7  62.4  9220600     59.4
##  3 2016-01-06  61.3  62.0  61.2  61.5  6551600     58.5
##  4 2016-01-07  60.4  61.3  59.8  59.8 10881300     57.0
##  5 2016-01-08  60.1  60.8  58.7  58.9 11191300     56.0
##  6 2016-01-11  59.0  60.0  58.5  59.5 12825000     56.7
##  7 2016-01-12  60.3  60.8  59.6  59.9  8292200     57.0
##  8 2016-01-13  60.5  60.5  58.7  58.8  9944300     55.9
##  9 2016-01-14  59    59.3  57.3  58.5  9989000     55.7
## 10 2016-01-15  56.9  58.1  56.6  57.6 12208300     54.8
## # … with 1,018 more rows

Q2 How many columns (variables) are there?

7 columns

Q3 Interpret the second observation?

The stock keeps going up from 01/04/16 to 01/15/16 67 times to be exact.

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.

Walmart has numeric data and the other kinds include logical and character.

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.

## Visualize
stocks %>%
  ggplot(aes(x = date, y = adjusted)) +
  geom_line()

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 Walmart stock has performed since the beginning of 2019.

Walmarts stock has been going up with a few drops here and there in their stock but they are mostly going in a upward slope.

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.