1. Learn
  2. /
  3. Courses
  4. /
  5. Credit Risk Modeling in R

Connected

Exercise

Replacing missing data

Rather than deleting the missing interest rates, you may want to replace them instead. The object na_index, which contains the index of the observations with missing interest rates is still loaded in your workspace.

Instructions

100 XP
  • Create an object called median_ir, containing the median of the interest rates in loan_data using the median() function. Don't forget to include the argument na.rm = TRUE.
  • In the new data set loan_data_replace, replace all the missing instances in the indices stored in object na_index with the median of all the interest rates, median_ir.
  • Have a look at the variable int_rate in the new data set using summary() to make sure that the NAs are gone.