Challenge: Visualize the Data

Use the concepts you learned about data visualization to complete the task.

We'll cover the following

Blog traffic dashboard

Suppose you are analyzing website traffic data for a blog over a week, and you want to create a visualization that shows the number of daily page views as well as the average time spent on the site each day. To do this, you can create a bar chart to show the number of daily page views and a line chart to show the average time spent on the site each day.

Follow the steps to create the chart:

  1. Read the data from the CSV file, located here:
  1. Create a ggplot() layer and define the common variables that will be used in both chart types.

  2. Add the geom_bar() layer and define the columns that differ from the line layer. Also, specify the value for the stat argument.

  3. Add a geom_line() layer and define the distinct column. Please scale the data to be able to show the line in the chart. Also, specify that the data comes from one category.

  4. Add a geom_point() layer that uses the same data as the line plot. We create this layer to increase the visibility of the points on the line chart.

  5. Add a secondary y-axis to the chart and scale it appropriately. Make sure that the secondary axis correctly shows the average time spent.

Note: Use different colors for each layer. Try to improve the interpretability and visibility of the chart. Feel free to experiment on different configuration arguments.

Get hands-on with 1200+ tech skills courses.