Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Creating functions
11. Arguments' default values
If statements


Good job! Some arguments in an R function can have a default value. Take a look at the modified definition of the low_quality_column() function:

low_quality_column <- function(column, threshold = 0.5){
  number_of_missings <- sum( / length(column)
  return(number_of_missings > threshold)

There are two arguments here: column and threshold. Notice that threshold is defined as 0.5 in the argument list. This is a default argument. Basically, it means users don't have to pass in a value for that argument if they don't want to. If they don't, the function simply uses the default value of 0.5. But if they do pass in a value, the function will replace the default.

In our example, you can call the low_quality_column function with only one argument by specifying the value for the column.


Call the low_quality_column function by passing in only the city column of the survey data frame. Don't specify a custom threshold.