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
## Examine data
glimpse(stocks)
## Visualize
stocks %>%
ggplot(aes(x = date, y = close)) +
geom_line()
Hint: Insert a new code chunk below and type in the code, using the tq_get() function above. Replace the ticker symbol for Microsoft. 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("MSFT", get = "stock.prices", from = "2016-01-01")
stocks
Hint: Insert a new code chunk below and type in the code, using the glimpse() function above.
## Examine data
glimpse(stocks)
date, open, high, low, close, volume, adjusted
Hint: Watch the video, “Basic Data Types”, in DataCamp: Introduction to R for Finance: Ch1 The Basics.
They are numeric data, meaning they are numbers and not characters. Otherr basic types of data are character data and logical data.
There are 922 rows
Daily information about stock prices
Hint: Insert a new code chunk below and type in the code, using the ggplot() function above. For more information on the ggplot() function, refer to Ch2 Introduction to ggplot2 in one of our e-textbooks, Data Visualization with R.
## Visualize
stocks %>%
ggplot(aes(x = date, y = close)) +
geom_line()
Hint: Change message, warning, collapse, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.