library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyr)
library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
# Datos: http://data.insideairbnb.com/chile/rm/santiago/2022-09-22/data/listings.csv.gz
# Ejemplo: https://www.kaggle.com/code/dgomonov/data-exploration-on-nyc-airbnb

airbnb=read.csv("listings.csv")
# Limpiar el precio, se reemplaza el signo peso y la coma por un string vacío

head(as.numeric(gsub('\\$|,', '',airbnb$price)))
## [1]  30000  70000  49590  50526 149999  56140
# Dataframe limpio / falta remover outliers

airbnb_clean<-data.frame(as.numeric(gsub('\\$|,', '',airbnb$price)),airbnb$neighbourhood_cleansed)
colnames(airbnb_clean)=c("precio","comuna")

fig <- plot_ly(airbnb_clean, y = ~precio, color = ~comuna, type = "box")
fig
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors

## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors