Introduction to Dplyr

Code and text for Quiz 3.

Read the data into R.

corp_tax <- read_excel(here("corp_tax.xlsx"))
corp_tax %>% 
  filter(company == 'Masco')
# A tibble: 1 x 5
  company profit   tax tax_rate industry               
  <chr>    <dbl> <dbl>    <dbl> <chr>                  
1 Masco     789.  127.    0.161 Metals & metal products
Find the company in the Internet Services & Retailing industry with the highest profit.
corp_tax %>% 
  filter(industry == 'Internet Services & Retailing') %>% 
  slice_max(profit,n=1)
# A tibble: 1 x 5
  company  profit   tax tax_rate industry                     
  <chr>     <dbl> <dbl>    <dbl> <chr>                        
1 Facebook   8624  1747    0.203 Internet Services & Retailing

Distill is a publication format for scientific and technical writing, native to the web.

Learn more about using Distill at https://rstudio.github.io/distill.