Get startedGet started for free

Visualize imported data

It's important to check your imported data is reasonable. A plot is a quick and easy way to spot oddities. In this exercise, you will use the plot() function to visualize some AAPL data from Yahoo Finance.

A stock split caused a huge price change in June 2014. Apple simultaneously increased the number of shares outstanding and decreased its stock price, leaving the company value unchanged. For example, a 2-for-1 split would double the shares outstanding, and reduce the stock price by 1/2.

You will also use the quantmod extractor functions Cl() and Ad() to access the close and adjusted close columns, respectively. Yahoo Finance provides the split- and/or dividend-adjusted close column. You will learn more about the adjustment process in the next video.

This exercise is part of the course

Importing and Managing Financial Data in R

View Course

Exercise instructions

AAPL is available in your workspace - consisting of Apple stock data (imported from Yahoo Finance) from January 2007 through September 15, 2017.

  • Look at the tail() of AAPL.
  • Plot the AAPL close price.
  • Plot the AAPL adjusted close price.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Look at the last few rows of AAPL data


# Plot close price


# Plot adjusted close price
Edit and Run Code