Exploratory analysis II

Data visualization, part 2. Code for Quiz 8

  1. Load the R package we will use.
  1. Quiz questions
  1. Pick one of your plots to save as your preview plot. Use the ggsave command at the end of the chunk of the plot that you want to preview.

Question: modify slide 51


Modify facet-ex-2

-add facet_grid to split the data into panels based on the class - let scales vary across columns - let space taken up by panels vary by columns


Question:spend_time

To help you complete this question use:

Download the file spend_time.csv from moodle into directory for this post. Or read it in directly:

read_csv(“https://estanny.com/static/week8/spend_time.csv”)


Start with spend_time - extract observations for 2018 - THEN create a plot with that data - ADD a barchart with with geom_col - assign activity to the x-axi s - assign avg_hours to the y-axis - assign activity to fill - ADD scale_y_continuous with breaks every hour from 0 to 6 hours - ADD labs to - set subtitle to Avg hours per day: 2018 - set x and y to NULL so they won’t be labeled - assign the output to p1 - display p1


Start with spend_time


Use patchwork to display p1 on top of p2


Start with p_all


Start with p_all_no_legend


Question:Patchwork 2

use spend_time from last question patchwork slides

Start with spend_time


Start with p4


Start with spend_time


Use patchwork to display p4 and p5 on top of p6