Summer Deals - hours only!Up to 80% off on all courses and bundles.-Close
Creating data frames
Feature engineering
Summary

Instruction

Perfect! Often, you'll need to create and overwrite column values based on conditions.

For example, let's say you want to create a column named price_category using the following conditions:

  • The value is equal to "low" if price is less than or equal to 90 000 EUR.
  • The value is equal to "medium" if price is greater than 90 000 EUR and less than or equal to 120 000 EUR.
  • The value is equal to "high" if price is greater than 120 000 EUR.

Over the next few exercises, we'll guide you through creating this column.

Exercise

To start, let's create a new column named price_category in the houses data frame. Assign a character value of "0" to that column. This step creates the new column price_category. We'll modify it in the next exercise.

Stuck? Here's a hint!

You should write:

houses$price_category <- "0"