Exercises

There are a couple of sample dataframes in R. For this exercise, we will work with some of them. We will also train your “help yourself” instincts. There is ample help on the web. Platforms like stackoverflow provide great answers to most of your R-related questions.

Let’s give it a try.

Example 1)

                            # Load the data set on USA Arrest rates.
                            data
                            (
                            "USArrests"
                            )

Answer the following questions (with the help of online resources).

  1. Sort the data by the Murder rate. Which state has the highest murder rate?
  2. What is the average murder rate across all states?
  3. What is the correlation between urban population and murder rates?

Example 2)

                            # Let's look at some data on judges.
                            data
                            (
                            "USJudgeRatings"
                            )
  1. What judge has the highest overall rating?
  2. Which category is the highest rated overall?

Example 3)

                            # Finally, let's take a look at Canada and the Canadian lynx dataset.
                            data
                            (
                            "lynx"
                            )
  1. Plot the number of lynx hunted every year.
  2. Try different plot types. Which visualization is most appropriate?

access_time Last update May 8, 2020.

chat networking coding local-network layer menu folders diagram panel route line-chart compass search flow data-sharing search-1 message target translator candidates studying chat networking coding local-network layer menu folders diagram panel route line-chart compass search flow data-sharing search-1 message target translator candidates studying