Exercise

# Counting Missing Values

SAS, SPSS and Stata have functions to **count the valid values** of a vector: N, NVALID and rownonmiss. R does not have such a function, but it is possible to create one on your own. For example:

```
n.valid <- function(x) {sum(!is.na(x))}
```

In general, you can write your own function via:

```
my_function_name <- function(x) {
my_function_code
}
```

Given the above, construct a function to count the number of **missing values** in R. The vector `QR3`

is preloaded in the workspace.

Instructions

**100 XP**

- Create a function to calculate the number of missing values by using the function
`function()`

and call this function`n.missing`

. - Use your function to calculate the number of missing values of
`QR3`

and assign the result to`missing_count`

.