-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvisualization.Rmd
67 lines (56 loc) · 1.41 KB
/
visualization.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
title: "cse-assignment-2"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(readr)
library(tidyverse)
df_ca <- read_csv("df_ca.csv")
#View(df_ca)
```
```{r}
df_ca_f <- df_ca %>%
drop_na()
```
```{r}
summ_by_price <- df_ca_f %>%
group_by(price, hour) %>%
summarise(avg_rating = mean(rating))
```
```{r}
# Avg. rating across different price levels across hours of the day
gr_scale = gray.colors(3, start = 0.3, end = 0.6, gamma = 2.2, alpha = NULL, rev = FALSE)
ggplot(summ_by_price, aes(x=hour, y = avg_rating, group = price, color = price)) +
geom_point(size = 2) +
geom_line() +
scale_colour_manual(values = c("$" = "#AEAEAE", "$$" = "#7A7A7A", "$$$" = "#4D4D4D")) +
xlab('Hour') +
ylab('Avg. Rating') +
labs(color='Price') +
ggtitle('Change in avg. rating for different price levels') +
theme_light()
```
```{r}
df_ca_02 <- read_csv("df_ca_02.csv")
df_ca_02 <- df_ca_02 %>%
drop_na()
```
```{r}
#rev_len_by_rating <- df_ca_02 %>%
df_ca_02 %>%
filter(rating != 0) %>%
ggplot(aes(x=reviewLength)) +
geom_histogram(breaks=seq(0, 2500, by=1)) +
xlim(c(0, 500)) +
#scale_x_continuous(breaks = seq(0, 1000, 5)) +
facet_wrap(~rating) +
xlab('Length of review') +
ylab('Number of reviews') +
ggtitle('Distribution of review lengths from 1 to 5 ratings') +
theme_bw()
```