Actividad 1

Paso 1. Filtrar un barrio de interes y solo apartamentos:

library(readxl)
datos= read_excel("D:/GUIANCARLO_2022/MAESTRIA CIENCIA DE DATOS/Metodos y Simulacion Estadistica/Actividad 1_16_02_2022/Datos_Vivienda.xlsx")

ID=1:dim(datos)[1]
datos=data.frame(ID,datos)

pos=which(datos$Barrio=="multicentro")
datos_sub=datos[pos,]

require(RecordLinkage)

pos2=which(jarowinkler("ingenio",datos$Barrio)>0.8 & datos$Tipo=="Apartamento")
datos_sub=datos[pos2,]
head(datos_sub)
ID Zona piso Estrato precio_millon Area_contruida parqueaderos Banos Habitaciones Tipo Barrio cordenada_longitud Cordenada_latitud
123 123 Zona Sur 3 5 290 100 1 3 3 Apartamento el ingenio -76.48498 3.41789
221 221 Zona Sur 4 5 360 99 1 3 2 Apartamento el ingenio -76.48953 3.49684
582 582 Zona Sur NA 4 550 197 2 4 3 Apartamento el ingenio -76.49900 3.47100
2397 2397 Zona Sur 2 5 410 136 2 4 4 Apartamento el ingenio -76.52000 3.37900
2446 2446 Zona Sur 4 5 390 198 1 4 3 Apartamento el ingenio -76.52030 3.38197
2792 2792 Zona Sur NA 5 300 147 2 3 3 Apartamento el ingenio -76.52200 3.38100

paso 2. Exploracion Inicial

##Tabla de indicadores importantes

promedio_precio=mean(datos_sub$precio_millon,na.rm=TRUE)
mediana_precio=median(datos_sub$precio_millon,na.rm=TRUE)
promedio_area=mean(datos_sub$Area_contruida,na.rm=TRUE)
cantidad_ofertas=length(datos_sub$Zona)

resultado=data.frame(promedio_precio,mediana_precio,promedio_area,cantidad_ofertas)
resultado
promedio_precio mediana_precio promedio_area cantidad_ofertas
316.6846 300 117.7467 130

Pao 3. Visualización en Mapa Interactivo

require(leaflet)
## Loading required package: leaflet
leaflet()%>%addCircleMarkers(lng=datos_sub$cordenada_longitud,lat=datos_sub$Cordenada_latitud,radius=0.3,color="black",label=datos_sub$ID)%>%addTiles()
  1. Exploración Bivariada Entre Precio vS area Construida
require(ggplot2)
## Loading required package: ggplot2
require(plotly)
## Loading required package: plotly
## 
## 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
g1=ggplot(data=datos_sub, aes(y=precio_millon,x=Area_contruida))+geom_point()+geom_smooth()
ggplotly(g1)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
pos3=which(datos_sub$Area_contruida<400)
datos_sub2=datos_sub[pos3,]

g2=ggplot(data=datos_sub2,aes(y=precio_millon,x=Area_contruida))+geom_point()+geom_smooth()
ggplotly(g2)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'