knitr::opts_chunk$set(echo = TRUE)

Load Data

library(dplyr)
library(tidyverse)

nyc_coffee <- read_csv("nyc_BB.csv")
brooklyn_coffee <- read_csv("Brooklyn_BB.csv")
bronx_coffee <- read_csv("Bronx_BB.csv")
manhattan_coffee <- read_csv("manhattan_BB.csv")
statenisland_coffee <- read_csv("StatenIsland_BB.csv")
queens_coffee <- read_csv("Queens_BB.csv")

Assign Boroughs

nyc_coffee$borough <- "All Boroughs"
brooklyn_coffee$borough <- "Brooklyn"
bronx_coffee$borough <- "Bronx"
manhattan_coffee$borough <- "Manhattan"
queens_coffee$borough <- "Queens"
statenisland_coffee$borough <- "Staten Island"
all_nyc <- rbind(brooklyn_coffee, bronx_coffee, manhattan_coffee, queens_coffee,statenisland_coffee)
nyc_bb <- all_nyc %>% 
  filter(state == "NY") %>% 
  group_by(full_address, name, zip_code) %>% 
  summarize(ave_rating = mean(rating, na.rm = T),
           ave_review_count = mean(review_count, na.rm = T),
           num = n()) %>% 
    arrange(desc(num)) %>% 
  mutate(NAME = case_when(
      str_detect(name, "^Blue Bottle") ~ "BB",
      TRUE ~ name
      )) %>% 
  filter(NAME == "BB")

write_csv(nyc_bb, "./full_nyc_BB.csv", na = "NA" )
table(all_nyc$borough)


nikkyxiong/coffee_rating_and_nyc_demographics documentation built on May 16, 2020, 9:27 a.m.