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 The first 6 rows of the dataset are
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
The first 6 rows of the dataset are as shown below:
Provide the simplest R code and output for all of the following. The code should work for any given data.
a) Store the result of the summary function for the Close attribute as the variable sm. Change the names of this variable so that the output appears as shown below.
Using the above data, show the quartile variations for the 4 quartiles as shown below. You can use paste or sprintf.
b) Produce the output for the minimum of the Dow closing value in the dataset as shown below:
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.
d) 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.
e) How many days did the Dow close higher than its previous day value? How many days did the Dow close lower than its previous day value?
f) Show the subset of the data where there was a gain of at least 1000 points from its previous day value.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started