The function nchar tells you how many characters long a character vector is.

Example

nchar("Hello")
#> [1] 5

Write a line of code that assigns to the object new_names the state abbreviation when the state name is longer than 8 characters and the original name when this is not the case. The state names are those from the murders dataset.


NOTE

Do not forget to first load the data as in the previous exercises!

You will need to use the ifelse function from chapter 3.1 Conditional expressions.

The ifelse function is not the same as if(){} else{} statements.