Spring Deals - hours only!Up to 70% off on all courses and bundles.-Close
Creating data frames
3. Creating a data frame with the data.frame() function


Nicely done! Now, we can create a data frame called quarter_prices whose columns are these two vectors. To do so, we'll use the data.frame() function, like this:

quarter_prices <- data.frame(period, avg_price)

When we run this line of code, R will create a data frame that looks like this:

period avg_price
1 Q1 2017 170195
2 Q2 2017 173937
3 Q3 2017 177938

The data.frame() function takes vector arguments that represent the columns of the data frame you wish to create. In this case, our column vectors are period and avg_price. We then told R to store this data frame object in a column named quarter_prices.


Create a data frame named houses from two vectors that we've already defined for you: ad_code and price (in that order). How many rows are in this newly created data frame?