Perfect! Of course, most of the time you'll create new columns using information from other columns in a data frame. For example, the
avg_price column currently represents average housing prices in Euros.
Let's create an additional column called
avg_price_usd that will represent average housing prices in dollars. We'll use existing columns to calculate this price:
avg_price (which is the average price in Euros), and
conversion_rate (which equals 1.20). Here's the expression:
quarter_prices$avg_price_usd <- quarter_prices$avg_price * quarter_prices$conversion_rate
This expression will create a vector with average price converted to USD and it will assign this vector to a new column
avg_price_usd in the
quarter_prices data frame.