Session Ready
Exercise

Find indices associated with the dates 3/1/1994 and 3/1/1995

It will often be useful to select stock data between certain dates. Advanced users are advised to look at the xts package. However, base R also provides sufficient functionality to do this.

The which() function returns the indices for which a condition is TRUE. For example: which(sbux_df$Date == "3/1/1994") returns the position of the date 3/1/1994, which indicates in this case the row number in the sbux_df data frame.

Instructions
100 XP
  • Assign to index_1 the row number of the row that contains the price on 3/1/1994.
  • Assign to index_2 the row number of the row that contains the price on 3/1/1995.
  • Assign to some_prices the SBUX closing prices between 3/1/1994 and 3/1/1995.