-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.r
More file actions
31 lines (24 loc) · 829 Bytes
/
code.r
File metadata and controls
31 lines (24 loc) · 829 Bytes
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
# install packages
if(!require(gistr))install.packages("gistr")
if(!requireNamespace("animint2"))install.packages("animint2")
library(ggplot2)
require(animint2)
require(gistr)
# load data
airbnb.data <- read.csv(url("https://www.kaggle.com/rusiano/madrid-airbnb-data#listings_detailed.csv"))
head(airbnb.data)
# subset
airbnb.centro.data <- subset(airbnb.data, neighbourhood == 'Centro')
df <- data.frame(airbnb.centro.data)
df$price <- as.numeric(df$price)
df$bedrooms <- as.character(df$bedrooms)
# check the maximum of the price to set the y axis appropriately
max(df$price)
# plot data
scatter <- ggplot() + geom_jitter(mapping=aes(x=review_scores_value, y=price, color=bedrooms), data=df) + coord_cartesian(ylim = c(0, 500))
# print plot
scatter
# interactive plot
viz <- animint(scatter)
# publish
animint2gist(viz)