Skip to Content
R Programming Fundamentals
book

R Programming Fundamentals

by Kaelen Medeiros
September 2018
Beginner
206 pages
4h 27m
English
Packt Publishing
Content preview from R Programming Fundamentals

Using dplyr Methods to Create Data Summary Tables

We will utilize the dplyr verbs to create complex data summary tables. In order to do so, the following steps need to be executed:

  1. Load the diamonds dataset using the following code:
data(diamonds) 
  1. Group the data by cut, color, and clarity, and find the number of observations at each combination of the three variables, as follows:
diamonds %>% group_by(cut, color, clarity) %>% summarise(n())
  1. Find the mean and median price of diamonds by using the dplyr functions group_by() and summarise() as follows:
diamonds %>% group_by(cut) %>% summarise(mean = mean(price), median = median(price))
  1. We can also filter out data we're not interested in quickly using dplyr methods. Say we don't want ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

R Programming Fundamentals

R Programming Fundamentals

Samik Sen, Marcin Dubel
Python for Programmers

Python for Programmers

Paul Deitel, Harvey Deitel

Publisher Resources

ISBN: 9781789612998Supplemental Content