Aan de slagGa gratis aan de slag

Orienting with the data

Let's take our first look at the new speeding dataset.

First, print the data frame to your screen and try and get a sense of it. You can use filter()s, group_by()s or any of your tidyverse functions to do this.

The supplied code is what we used to make the histogram of blue car speeds in the slides. Modify this code to look at how many miles-per-hour red cars were going over the speed limit (speed_over). Give the plot a title while you're at it to let people know what they're looking at.

Deze oefening maakt deel uit van de cursus

Visualization Best Practices in R

Cursus bekijken

Oefeninstructies

  • Print the md_speeding data frame to the console and investigate it.
  • Change filter() to 'RED' cars.
  • Change column of interest to speed_over.
  • Title plot 'MPH over speed limit | Red cars'

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Print data to console
___

# Change filter to red cars
md_speeding %>% 
	filter(vehicle_color == 'BLUE') %>% 
	# switch x mapping to speed_over column
	ggplot(aes(x = speed)) +
	geom_histogram() +
	# give plot a title
	
Code bewerken en uitvoeren