Exercise

# Adjust univariate data for splits and dividends

If you only have close prices, you can adjust them with `adjRatios()`

. It has 3 arguments: `splits`

, `dividends`

, and `close`

. It returns an xts object with split and dividend adjustment ratios in columns `"Split"`

and `"Div"`

, respectively.

You need to provide split data via the `splits`

argument to calculate the split ratio. To calculate the dividend ratio, you need to provide *raw* dividends and *raw* prices via the `dividends`

and `close`

arguments, respectively.

Once you have the split and dividend adjustment ratios, you calculate the adjusted price multiplying the unadjusted price by both the split and dividend adjustment ratios.

Your workspace contains `splits`

, `dividends`

, and `raw_dividends`

from prior exercises, and `AAPL`

data from Yahoo Finance.

Instructions

**100 XP**

- Use
`adjRatios()`

to calculate the split and dividend adjustment ratios. Assign the output to`ratios`

. - Calculate the adjusted close for AAPL by extracting the close price and multiplying it by both adjustment ratios and assign it to
`aapl_adjusted`

. - Look at the first few rows of the adjusted close column provided by Yahoo Finance.
- Look at the first few rows of the adjusted close price you calculated, and compare that to the adjusted close from Yahoo Finance.