Creating data frames
Summary
17. Creating data frames and adding new columns - summary

Instruction

Awesome! We're almost done with Part 4! Our emphasis in this part of the course was on creating data frames, and creating new columns. Let's summarize what we’ve learned.

You can create data frames in R by using the data.frame() function:

house_prices <- data.frame(
  house_type = c("Detached", "Semi-detached", "Bungalow"),
  house_price = c(690000, 500000, 750000))

You can load data from a CSV file by using the read.csv() function:

houses <- read.csv("data/houses.csv")

Next, we discussed how you can add new columns to a data frame or overwrite values in an existing column. You can add new column to a data frame like this:

houses$quality <- 5

You can also overwrite values in an existing column based on some condition:

houses[houses$price > 160000, "price"] <- 160000

Exercise

Let's do a few summary exercises. Click Next exercise to begin.