Go to Yahoo Finance and import Microsoft stock prices from December 13, 1990 to July 31, 2017.

Q1 How many columns does the imported data have?

##         Date     Open     High      Low    Close Adj.Close   Volume
## 1 1990-12-13 1.013889 1.020833 0.996528 1.010417  0.736435 50707200
## 2 1990-12-14 1.013889 1.031250 1.006944 1.022569  0.745293 48633600
## 3 1990-12-17 1.013889 1.031250 1.006944 1.027778  0.749089 27286400
## 4 1990-12-18 1.034722 1.052083 1.031250 1.045139  0.761742 51872000
## 5 1990-12-19 1.046875 1.052083 1.038194 1.039931  0.757946 34262400
## 6 1990-12-20 1.031250 1.055556 1.027778 1.048611  0.764273 46992000
##            Date  Open  High   Low Close Adj.Close   Volume
## 6704 2017-07-24 73.53 73.75 73.13 73.60  71.91389 21394800
## 6705 2017-07-25 73.80 74.31 73.50 74.19  72.49037 22018700
## 6706 2017-07-26 74.34 74.38 73.81 74.05  72.35358 16252200
## 6707 2017-07-27 73.76 74.42 72.32 73.16  71.48397 36844200
## 6708 2017-07-28 72.67 73.31 72.54 73.04  71.36671 18306700
## 6709 2017-07-31 73.30 73.44 72.41 72.70  71.03450 23600100

Convert the date variable from a Factor to a Date.

Q2 How is the date ordered in the original imported data (i.e., Year-Day-Month, Month/Day/Year)?

## [1] "factor"
## [1] "Date"

Combine date and data.MSFT.

##         date     Open     High      Low    Close Adj.Close   Volume
## 1 1990-12-13 1.013889 1.020833 0.996528 1.010417  0.736435 50707200
## 2 1990-12-14 1.013889 1.031250 1.006944 1.022569  0.745293 48633600
## 3 1990-12-17 1.013889 1.031250 1.006944 1.027778  0.749089 27286400
## 4 1990-12-18 1.034722 1.052083 1.031250 1.045139  0.761742 51872000
## 5 1990-12-19 1.046875 1.052083 1.038194 1.039931  0.757946 34262400
## 6 1990-12-20 1.031250 1.055556 1.027778 1.048611  0.764273 46992000
##            date  Open  High   Low Close Adj.Close   Volume
## 6704 2017-07-24 73.53 73.75 73.13 73.60  71.91389 21394800
## 6705 2017-07-25 73.80 74.31 73.50 74.19  72.49037 22018700
## 6706 2017-07-26 74.34 74.38 73.81 74.05  72.35358 16252200
## 6707 2017-07-27 73.76 74.42 72.32 73.16  71.48397 36844200
## 6708 2017-07-28 72.67 73.31 72.54 73.04  71.36671 18306700
## 6709 2017-07-31 73.30 73.44 72.41 72.70  71.03450 23600100

Sort the data in chronological order.

##         date     Open     High      Low    Close Adj.Close   Volume
## 1 1990-12-13 1.013889 1.020833 0.996528 1.010417  0.736435 50707200
## 2 1990-12-14 1.013889 1.031250 1.006944 1.022569  0.745293 48633600
## 3 1990-12-17 1.013889 1.031250 1.006944 1.027778  0.749089 27286400
## 4 1990-12-18 1.034722 1.052083 1.031250 1.045139  0.761742 51872000
## 5 1990-12-19 1.046875 1.052083 1.038194 1.039931  0.757946 34262400
## 6 1990-12-20 1.031250 1.055556 1.027778 1.048611  0.764273 46992000
##            date  Open  High   Low Close Adj.Close   Volume
## 6704 2017-07-24 73.53 73.75 73.13 73.60  71.91389 21394800
## 6705 2017-07-25 73.80 74.31 73.50 74.19  72.49037 22018700
## 6706 2017-07-26 74.34 74.38 73.81 74.05  72.35358 16252200
## 6707 2017-07-27 73.76 74.42 72.32 73.16  71.48397 36844200
## 6708 2017-07-28 72.67 73.31 72.54 73.04  71.36671 18306700
## 6709 2017-07-31 73.30 73.44 72.41 72.70  71.03450 23600100

Convert data.frame object to xts object.

Q3 How many variables (columns) does your data have now?

## [1] "data.frame"
## [1] "xts" "zoo"

Rename variables

Q4 What is the name of the first column?

## [1] "Open"      "High"      "Low"       "Close"     "Adj.Close" "Volume"
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Adjusted
## 1990-12-13  1.013889  1.020833 0.996528   1.010417      0.736435
## 1990-12-14  1.013889  1.031250 1.006944   1.022569      0.745293
## 1990-12-17  1.013889  1.031250 1.006944   1.027778      0.749089
## 1990-12-18  1.034722  1.052083 1.031250   1.045139      0.761742
## 1990-12-19  1.046875  1.052083 1.038194   1.039931      0.757946
## 1990-12-20  1.031250  1.055556 1.027778   1.048611      0.764273
##            MSFT.Volume
## 1990-12-13    50707200
## 1990-12-14    48633600
## 1990-12-17    27286400
## 1990-12-18    51872000
## 1990-12-19    34262400
## 1990-12-20    46992000
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Adjusted
## 2017-07-24     73.53     73.75    73.13      73.60      71.91389
## 2017-07-25     73.80     74.31    73.50      74.19      72.49037
## 2017-07-26     74.34     74.38    73.81      74.05      72.35358
## 2017-07-27     73.76     74.42    72.32      73.16      71.48397
## 2017-07-28     72.67     73.31    72.54      73.04      71.36671
## 2017-07-31     73.30     73.44    72.41      72.70      71.03450
##            MSFT.Volume
## 2017-07-24    21394800
## 2017-07-25    22018700
## 2017-07-26    16252200
## 2017-07-27    36844200
## 2017-07-28    18306700
## 2017-07-31    23600100

Plot the data

Q5 What month and year during the study period does the stock reach the highest point?

Q6 During what stretch of time in the data, would an investor have won the largest return? Conversely, during what stretch of the time, would an investor have lost the largest sum?