29. Exercise 4


Great! Now our two columns no longer have any missing values.


Create a column named renovation_status.

  • If the built column is greater than 2010 then renovation_status is equal to "new".
  • If the last_renovation column is greater than 2010, renovation_status is equal to "renovated".
  • Otherwise the renovation_status is "old".

Stuck? Here's a hint!

First, create the renovation_status column and assign the "old" to all rows:

houses$renovation_status <- "old"

Now we can change the value for desired rows that meet certain conditions. For the houses build after 2010:

houses[houses$built > 2010,]$renovation_status <- "new"

For the houses that were renovated after the 2010:

houses[houses$last_renovation > 2010, ]$renovation_status <- "renovated"