For these exercises we will use the US murders dataset. Make sure you load it prior to starting.

library(dslabs)
data("murders")

1. Use the $ operator to access the population size data and store it as the object pop. Then use the sort function to redefine pop so that it is sorted. Finally, use the [ operator to report the smallest population size. Store the smallest population size in pop_min

2. Now instead of the smallest population size, find the index of the entry with the smallest population size in the unsorted population size data. Hint: use order instead of sort. store the index in pop_min_index

3. We can actually perform the same operation as in the previous exercise using the function which.min. Write one line of code that does this. Store your result in pop_min_index_wm

4. Now we know how small the smallest state is and we know which row represents it. Which state is it? Define a variable states to be the state names from the murders data frame. Report the name of the state with the smallest population and store it in smallest_city