estatedf <- read.table(file = "/home/xps13/src/R/estate/inst/extdata/enalquiler-2017-10-04.tsv", header = TRUE, sep = "\t")
data_plot <-
estatedf %>%
filter(price < 1000 &
bath < 3)
ggplot(data = data_plot, aes(x = price, y = size, color = factor(bath))) +
geom_point() +
geom_smooth(method = "lm") +
ggtitle("size: m^2, price: euro") +
theme(
legend.position = "top"
)
str(estatedf)
## 'data.frame': 841 obs. of 6 variables:
## $ price : int 650 750 1300 900 2500 750 700 1400 775 500 ...
## $ size : int 75 90 157 125 150 65 90 160 75 80 ...
## $ bath : int 1 2 2 2 2 2 1 2 1 1 ...
## $ title : Factor w/ 556 levels "88 m2, nuevo, zona San Lorenzo Alameda, amueblado, 2 hab",..: 412 205 70 65 57 470 457 322 412 322 ...
## $ location: Factor w/ 499 levels "Adelantado, Macarena, Resolana, Sevilla, Sevilla",..: 484 172 480 416 85 112 460 334 485 135 ...
## $ link : Factor w/ 841 levels "http://www.enalquiler.com/alquiler_piso_sevilla/88-m2-nuevo-zona-san-lorenzo-alameda-amueblado-2-hab_3324700.html",..: 681 346 178 164 130 466 437 521 680 520 ...
mod1 <- lm(price ~ size * bath, data = data_plot)
summary(mod1)
##
## Call:
## lm(formula = price ~ size * bath, data = data_plot)
##
## Residuals:
## Min 1Q Median 3Q Max
## -311.54 -93.96 -0.02 89.22 313.99
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 223.2962 66.0363 3.381 0.000762 ***
## size 5.0343 0.7936 6.343 4.1e-10 ***
## bath 146.7953 50.9886 2.879 0.004115 **
## size:bath -1.4358 0.5489 -2.616 0.009099 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 124.7 on 679 degrees of freedom
## Multiple R-squared: 0.2574, Adjusted R-squared: 0.2541
## F-statistic: 78.45 on 3 and 679 DF, p-value: < 2.2e-16
knitr::kable(head(estatedf))
price | size | bath | title | location | link |
---|---|---|---|---|---|
650 | 75 | 1 | Piso en Sevilla | Triana, Triana - Esperanza de Triana, Sevilla, Sevilla | http://www.enalquiler.com/alquiler_piso_sevilla/piso-en-sevilla_4848337.html |
750 | 90 | 2 | Estupendo piso de alquiler sin amueblar en nervión | Diego Martinez Barrio, Nervión, Diego Martinez Barrio, San Bernardo, Sevilla, Sevilla | http://www.enalquiler.com/alquiler_piso_sevilla/estupendo-piso-de-alquiler-sin-amueblar-en-nervion_4848170.html |
1300 | 157 | 2 | Alquiler piso ascensor y aire acondicionado Triana | Triana, Pagés del Corro-López de Gomara, Triana Casco Antiguo, Sevilla, Sevilla | http://www.enalquiler.com/alquiler_piso_sevilla/alquiler-piso-ascensor-y-aire-acondicionado-triana_4847776.html |
900 | 125 | 2 | Alquiler piso ascensor San pablo - santa justa | San Pablo - Santa Justa, Luis Montoto - Santa Justa, San José Obrero, Sevilla, Sevilla | http://www.enalquiler.com/alquiler_piso_sevilla/alquiler-piso-ascensor-san-pablo-santa-justa_4847728.html |
2500 | 150 | 2 | Alquiler piso ascensor Casco antiguo | Casco Antiguo, Arenal - Museo, Museo, Sevilla, Sevilla | http://www.enalquiler.com/alquiler_piso_sevilla/alquiler-piso-ascensor-casco-antiguo_4847725.html |
750 | 65 | 2 | Piso, Centro - Puerta Osario, 2 dormitorios. | Casco Antiguo, Puerta Osario, Santa Catalina, Sevilla, Sevilla | http://www.enalquiler.com/alquiler_piso_sevilla/piso-centro-puerta-osario-2-dormitorios_4847541.html |