_______ <- _______ |>
mutate(_______) |>
filter(_______) |>
select(_______)
_______ |>
group_by(______) |>
summarize(______) |>
arrange(_______)Lab 15: dplyr
Note
In lab.qmd ## Lab 15 section, import the murders.csv data and
Add (mutate) the variable
rate = total / population * 100000tomurdersdata (as I did).Filter states that are in region Northeast or West and their murder rate is less than 1.
Select variables
state,region,rate.
Print the output table after you do 1. to 3., and save it as object
my_states.Group
my_statesbyregion. Then summarize data by creating variablesavgandstdevthat compute the mean and standard deviation ofrate.Arrange the summarized table by
avg.
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