Lab 15: dplyr

Note

In lab.qmd ## Lab 15 section, import the murders.csv data and

  1. Add (mutate) the variable rate = total / population * 100000 to murders data (as I did).

  2. Filter states that are in region Northeast or West and their murder rate is less than 1.

  3. Select variables state, region, rate.

_______ <- _______ |> 
    mutate(_______) |> 
    filter(_______) |> 
    select(_______)

_______ |>  
    group_by(______) |> 
    summarize(______) |> 
    arrange(_______)
          state    region      rate
1        Hawaii      West 0.5145920
2         Idaho      West 0.7655102
3         Maine Northeast 0.8280881
4 New Hampshire Northeast 0.3798036
5        Oregon      West 0.9396843
6          Utah      West 0.7959810
7       Vermont Northeast 0.3196211
8       Wyoming      West 0.8871131
# A tibble: 2 × 3
  region      avg std_dev
  <fct>     <dbl>   <dbl>
1 West      0.781   0.164
2 Northeast 0.509   0.278