Session Ready
Exercise

Cleaning the names list

Now that you have a list of native Indian names, make sure that the list will do what you need it to. The list was taken from an online resource and may contain names that don't make sense or aren't useful.

Take a look at the list and see if any names don't fit. The unlist() displays the names well.

Looks like there are a few names that could select users that would be hard to tell whether they were native Indian or not.

The single character names like A., C. or K. may select users that we don't want. You should remove those names from the list before using it to select the native Indian users.

You can do this by finding a regular expression that will find all the names with a single character followed by a .. The regular expression [A-z]\\. should do the trick. Combine the regular expression with the grep function to locate the names that you want to eliminate. These locations can be used to eliminate just the names you don't want.

Instructions
100 XP
  • Display the names list with unlist()
  • Use grep and the regular expression [A-z]\\. to locate the names you want to eliminate
  • Double check that those are the right names
  • Remove the unwanted names from the indain_names list using -indian_names_remove; assign the result to indian_names_clean.
  • Display the cleaned names list with unlist()