Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
512 changes: 512 additions & 0 deletions .Rhistory

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
.Rproj.user
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
125 changes: 125 additions & 0 deletions analysis.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
title: "analysis and viz"
author: "Anna Duan"
date: "`r Sys.Date()`"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

library(tidyverse)
library(sf)
library(wordcloud2)
library(tm)
library(tigris)


neighs <- st_read("working data/phl_neighs.geojson") %>%
st_transform(4326) %>%
select(MAPNAME, Shape_Area)

restaurants <- st_read("data/restaurants_final.geojson")
top_cuisine_tract <- st_read("data/top_cuisine_tract.geojson")
top_cuisine_neigh <- st_read("data/top_cuisine_neigh.geojson")


cuisine_colors <- c("Caribbean" = "cyan", "Chinese" = "goldenrod2", "East_European" = "dodgerblue3", "Japanese" = "darkcyan", "Korean" = "orchid1", "Latin_American" = "pink2", "Mediterranean" = "olivedrab2", "Mexican" = "gold1", "Middle_Eastern" = "salmon1", "Soul_Food" = "lightblue1", "South_Asian" = "olivedrab4", "Thai" = "tan", "United_Kingdom" = "orchid3", "Vietnamese" = "salmon3", "West_African" = "darkslategray")
```

# Wordclouds
```{r wordclouds}
# Yelp description
text <- restaurants$title
docs <- Corpus(VectorSource(text)) %>%
tm_map(removeNumbers) %>%
tm_map(removePunctuation) %>%
tm_map(stripWhitespace) %>%
tm_map(., content_transformer(tolower)) %>%
tm_map(., removeWords, stopwords("english"))
dtm <- TermDocumentMatrix(docs)
matrix <- as.matrix(dtm)
words <- sort(rowSums(matrix),decreasing=TRUE)
df <- data.frame(word = names(words),freq=words) %>%
filter(!word %in% c('food', 'fast', 'restaurants', 'delivery', 'services',
'trucks', 'grocery', 'shops', 'stores', 'sports', 'bars',
'breakfast', 'brunch', 'new','convenience', 'stands', 'american'))

wordcloud2(data = df, size = 3, color = "random-light")

# Cuisine
text <- restaurants$cuisine
docs <- Corpus(VectorSource(text)) %>%
tm_map(removeNumbers) %>%
tm_map(removePunctuation) %>%
tm_map(stripWhitespace) %>%
tm_map(., content_transformer(tolower)) %>%
tm_map(., removeWords, stopwords("english"))
dtm <- TermDocumentMatrix(docs)
matrix <- as.matrix(dtm)
words <- sort(rowSums(matrix),decreasing=TRUE)

df <- data.frame(word = names(words),freq=words)

wordcloud2(data = df, size = 3, color = "random-light")
```
# Cuisine dist
```{r cuisine distribution}

# Location of all restaurants
ggplot() +
# geom_sf(data = st_union(neighs), fill = "gray90", color = "transparent") +
geom_sf(data = restaurants, color = "darkcyan", size = 0.5, alpha = 0.2) +
labs(
title = "Philadelphia Ethnic Restaurants",
subtitle = "n = 2,288"
) +
theme_void()


ggplot() +
geom_bar(data = restaurants, aes(x = cuisine_group), show.legend = FALSE, fill = "darkcyan") +
coord_flip() +
scale_x_discrete(limits = restaurants%>% count(cuisine_group) %>% arrange(n) %>% pull(cuisine_group)) +
labs(
x = "Cuisine group",
y = "Number of restaurants"
) +
theme_minimal() +
theme(text = element_text(color = "gray20"))
```

```{r map all restaurants}
# Map most common cuisine in each neighborhood
ggplot() +
geom_sf(data = st_union(neighs), fill = "gray95", color = "transparent") +
geom_sf(data = top_cuisine_neigh %>% filter(count > 2), aes(fill = cuisine), color = "white") +
scale_fill_manual(values = cuisine_colors) +
labs(
title = "Most Common Cuisine in Each Neighborhood",
fill = "Cuisine"
) +
theme_void()

# Map most common cuisine in each census tract
ggplot() +
geom_sf(data = top_cuisine_tract %>% filter(count > 2), aes(fill = cuisine), color = "white") +
scale_fill_manual(values = cuisine_colors) +
labs(
title = "Most Common Cuisine in Each Tract",
fill = "Cuisine"
) +
theme_void()

```

```{r spruce hill}
ggplot() +
geom_sf(data = spruce_hill_restaurants, aes(color = mid_east)) +
labs(
title = "Restaurants in Spruce Hill",
fill = "Cuisine"
) +
theme_void()

```
Binary file added archive/cloud - title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added archive/cloud-title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added archive/food types cloud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 21 additions & 4 deletions templates/scrollytelly/css/index.css → css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ body {
border-width: 0;
box-sizing: border-box;
height: 100vh;
font-family: Arial, sans-serif;
}

font-family: 'Open Sans', sans-serif;
img {
max-width: 100%;
}

.map-container {
Expand All @@ -23,6 +26,7 @@ body {
margin-top: -30vh;
z-index: 100;
pointer-events: none;
border-bottom: 1px solid transparent;
}

.slide {
Expand All @@ -31,15 +35,15 @@ body {
margin-left: auto;
margin-right: 2rem;
padding: 1rem;
box-shadow: -0.5rem 0 1rem rgba(0 0 0 / 50%);
border: 1px solid gray;
box-shadow: -0.5rem 0 1rem rgba(75, 73, 73, 50%);
border: 1px solid rgb(216, 214, 214);
border-radius: 0.5rem;
pointer-events: initial;

width: 25rem;

background-color: white;
color: black;
color: gray;
}

.slide:first-child {
Expand Down Expand Up @@ -81,3 +85,16 @@ body {
.slide-nav-select {
min-width: 0;
}

.legend {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I might recommend some background on your legend to make the text a little more readable on top of the map tiles.

Suggested change
.legend {
.legend {
padding: 0.5rem;
border: 1px solid #ccc;
border-radius: 0.5rem;
background-color: rgba(255 255 255 / 50%);

line-height: 18px;
color: #555;
}

.legend i {
width: 18px;
height: 18px;
float: left;
margin-right: 8px;
opacity: 0.7;
}
Loading