Pull up the help file for summarise using ?summarise in the Console. Read about the description, useful functions, and then scroll down to the examples. Copy the first example in the code chunk below and run it. What is is doing? Practice reading this code as a sentence!
Note There are two different pipes in R: |> and %>%. They have identical functionality for the scope of this course. I will be using the |> pipe, as it has some computational benefits beyond the scope of 295.
What happens when we group by more than one variable? Copy the code from above into the code chunk below, and also group by the vs variable. Comment on what happens.
mtcars|># data set andgroup_by(cyl, vs)|>#group the data by cyl and vssummarise(mean_displacement =mean(disp), n_count =n())#calculate summary stats```
`summarise()` has grouped output by 'cyl'. You can override using the `.groups`
argument.
We are going to use the penguins data set in the palmerpenguins Pull up the help file, and read more about the penguins we are going to study!
Plots
Here is a quick reference of all the different kinds of plots we can make using ggplot()! Check it out here!
Create visualizations of the distribution of weights of penguins.
Histogram
Make a histogram by filling in the … with the appropriate arguments. Set an appropriate binwidth. Hint: you can run names(data.set) in your console if you need a quick reminder on the variable names.