Exercise

Accessing and subsetting data frames (2)

As you might imagine, selecting a specific column from a data frame is a common manipulation. So common, in fact, that it was given its own shortcut, the $. The following return the same answer:

cash$cash_flow

[1] 1000 4000  550 1500 1100  750 6000

cash[,"cash_flow"]

[1] 1000 4000  550 1500 1100  750 6000

Useful right? Try it out!

Instructions

100 XP
  • Select the "year" column from cash using $.
  • Select the "cash_flow" column from cash using $ and multiply it by 2.
  • You can delete a column by assigning it NULL. Run the code that deletes "company".
  • Now print out cash again.