Session Ready
Exercise

All together now!

Great! You have learned a lot about operators and subsetting. This will serve you well in future data analysis projects. Let's do one last exercise that combines a number of operators together.

Instructions
100 XP

A new version of stocks is in your workspace.

  • First, print stocks. It contains Apple and Microsoft prices for December, 2016.
  • It seems like you have missing data. Let's investigate further. Use weekdays() on the date column, and assign it to stocks as the column, weekday.
  • View stocks now. The missing data is on weekends! This makes sense, the stock market is not open on weekends.
  • Remove the missing rows using subset(). Use!is.na() on apple as your condition. Assign this new data.frame to stocks_no_NA.
  • Now, you are interested in days where apple was above 117, or when micr was above 63. Use relational operators, |, and subset() to accomplish this with stocks_no_NA.