Assignment and variables (2)
Suppose you have $100 stored in my_money
, and your friend Dan has $200 dollars. To be clear, you decide to give Dan's money a variable name too. You want to know how much money the two of you have together. Now that each variable has a descriptive name, this is easy using the arithmetic you learned earlier:
my_money + dans_money
This exercise is part of the course
Introduction to R for Finance
Exercise instructions
my_money
has been defined for you.- Assign 200 to Dan's money.
- Follow the example in the exercise text and add your money to Dan's money.
- Add your money to Dan's money again, but this time save the result to our_money!
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Assign 100 to my_money
my_money <- 100
# Assign 200 to dans_money
# Add my_money and dans_money
# Add my_money and dans_money again, save the result to our_money