Best April deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Creating functions
9. Function arguments
If statements
Summary

## Instruction

Every function in R has zero or more inputs (arguments) and a single output (return value). So far, we've worked with functions that take a single argument, but we can have more. Take a look:

low_quality_column <- function(column, threshold){
percent_missing <- sum(is.na(column))/length(column)
return(percent_missing > threshold)
}

This function counts the number of values missing from the given column, computes the ratio of this number to the total size of the column, and then compares the ratio to a given threshold. If the percentage of missing values is above the threshold, the function returns TRUE; otherwise, it returns FALSE.

## Exercise

Call the low_quality_column() function, and check whether the survey\$birthyear column is of low quality. Use a threshold of 0.8—that is, the column is of low quality if more than 80% of its values are missing.