Question: Initialize the Dow Jones Industrials daily closing data, dow, using the read.csv function with the link: http://people.bu.edu/kalathur/datasets/DJI_2020.csv c) Suppose you have an index fund tied
Initialize the Dow Jones Industrials daily closing data, dow, using the read.csv function with the link: http://people.bu.edu/kalathur/datasets/DJI_2020.csv

c) Suppose you have an index fund tied to the Dow closing value. If you have invested on the minimum date, what date from the dataset you would have sold to gain the maximum percentage gain. The output is as shown below. Note that the code should be generic so that it works on any such dataset. [l] "I would sell on 4/29/20 when Dow is at 24634 for a gain of 32.50%" (I) Use the diff function to calculate the differences between consecutive closing values in the dataset. Insert the value 0 at the beginning of these differences. Add this result as the DIFFS column of the data frame. The result is as shown below. V head(dow) Date Close DIFFS 1/2/20 28869 0 1/3/20 28635 -234 1/6/20 28703 68 1/2/20 28584 -119 1/8/20 28245 161 1/9/20 28957 212 mU'IJI-LUNH
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
