From cc16535e636153ff20c58796d1f66c553fba11f9 Mon Sep 17 00:00:00 2001 From: yaemiku Date: Thu, 30 Apr 2026 14:46:10 +0200 Subject: [PATCH] chunkify --- projekt.html | 119 +++++++++++++++------------------------------------ projekt.rmd | 35 +++++++++------ 2 files changed, 57 insertions(+), 97 deletions(-) diff --git a/projekt.html b/projekt.html index 7021a2b..a4d9a77 100644 --- a/projekt.html +++ b/projekt.html @@ -405,74 +405,8 @@ has_cols <- grep("^has", names(rent), value = TRUE) rent[has_cols] <- lapply(rent[has_cols], function(x) { tolower(x) == "yes" }) -summary(rent) -
##       id                city               type            squareMeters   
-##  Length:70847       Length:70847       Length:70847       Min.   : 25.00  
-##  Class :character   Class :character   Class :character   1st Qu.: 40.00  
-##  Mode  :character   Mode  :character   Mode  :character   Median : 50.00  
-##                                                           Mean   : 55.25  
-##                                                           3rd Qu.: 64.00  
-##                                                           Max.   :150.00  
-##                                                                           
-##      rooms           floor         floorCount       buildYear    
-##  Min.   :1.000   Min.   : 1.00   Min.   : 1.000   Min.   :1850   
-##  1st Qu.:2.000   1st Qu.: 2.00   1st Qu.: 4.000   1st Qu.:1984   
-##  Median :2.000   Median : 3.00   Median : 5.000   Median :2010   
-##  Mean   :2.385   Mean   : 3.42   Mean   : 5.687   Mean   :1998   
-##  3rd Qu.:3.000   3rd Qu.: 4.00   3rd Qu.: 7.000   3rd Qu.:2020   
-##  Max.   :6.000   Max.   :30.00   Max.   :30.000   Max.   :2024   
-##                  NA's   :8613    NA's   :1379     NA's   :19682  
-##     latitude       longitude     centreDistance      poiCount     
-##  Min.   :49.98   Min.   :14.45   Min.   : 0.020   Min.   :  0.00  
-##  1st Qu.:51.08   1st Qu.:18.65   1st Qu.: 1.770   1st Qu.:  9.00  
-##  Median :52.19   Median :19.96   Median : 3.380   Median : 17.00  
-##  Mean   :51.79   Mean   :19.69   Mean   : 3.856   Mean   : 25.21  
-##  3rd Qu.:52.25   3rd Qu.:21.01   3rd Qu.: 5.420   3rd Qu.: 30.00  
-##  Max.   :54.58   Max.   :23.20   Max.   :16.620   Max.   :210.00  
-##                                                                   
-##  schoolDistance   clinicDistance   postOfficeDistance kindergartenDistance
-##  Min.   :0.0020   Min.   :0.0010   Min.   :0.0010     Min.   :0.0010      
-##  1st Qu.:0.1740   1st Qu.:0.3020   1st Qu.:0.2350     1st Qu.:0.1530      
-##  Median :0.2850   Median :0.5500   Median :0.3880     Median :0.2590      
-##  Mean   :0.3688   Mean   :0.7763   Mean   :0.4702     Mean   :0.3272      
-##  3rd Qu.:0.4490   3rd Qu.:0.9700   3rd Qu.:0.5850     3rd Qu.:0.4010      
-##  Max.   :4.8560   Max.   :4.9900   Max.   :4.9390     Max.   :4.7510      
-##  NA's   :15       NA's   :50       NA's   :26         NA's   :43          
-##  restaurantDistance collegeDistance pharmacyDistance  ownership        
-##  Min.   :0.001      Min.   :0.004   Min.   :0.0010   Length:70847      
-##  1st Qu.:0.087      1st Qu.:0.520   1st Qu.:0.1360   Class :character  
-##  Median :0.180      Median :0.971   Median :0.2310   Mode  :character  
-##  Mean   :0.261      Mean   :1.287   Mean   :0.3089                     
-##  3rd Qu.:0.329      3rd Qu.:1.809   3rd Qu.:0.3820                     
-##  Max.   :4.961      Max.   :5.000   Max.   :4.9860                     
-##  NA's   :154        NA's   :874     NA's   :80                         
-##  buildingMaterial    condition         hasParkingSpace hasBalcony     
-##  Length:70847       Length:70847       Mode :logical   Mode :logical  
-##  Class :character   Class :character   FALSE:43075     FALSE:27341    
-##  Mode  :character   Mode  :character   TRUE :27772     TRUE :43506    
-##                                                                       
-##                                                                       
-##                                                                       
-##                                                                       
-##  hasElevator     hasSecurity     hasStorageRoom      price      
-##  Mode :logical   Mode :logical   Mode :logical   Min.   :  346  
-##  FALSE:26784     FALSE:60614     FALSE:59833     1st Qu.: 2500  
-##  TRUE :44063     TRUE :10233     TRUE :11014     Median : 3100  
-##                                                  Mean   : 3853  
-##                                                  3rd Qu.: 4490  
-##                                                  Max.   :23000  
-##                                                                 
-##     month_id    
-##  Min.   :1.000  
-##  1st Qu.:3.000  
-##  Median :5.000  
-##  Mean   :4.556  
-##  3rd Qu.:7.000  
-##  Max.   :8.000  
-## 
-
ggplot(rent) + geom_point(aes(x=city, y=price, col=centreDistance), alpha=0.1, size=0.5) + scale_color_viridis_c()
-

-
rent_norm <- rent %>%
+
+rent_norm <- rent %>%
   group_by(city) %>%
   mutate(
     latitude_n  = as.numeric(scale(latitude)),
@@ -480,23 +414,40 @@ summary(rent)
price_n = (price - min(price)) / (max(price) - min(price)) ) %>% mutate() %>% - ungroup() - -ggplot(rent_norm) + geom_point(aes(x=longitude_n, y=latitude_n, col=log(price)), alpha=0.01, size=0.2) + facet_wrap(~ city) + scale_color_viridis_c() -

+ ungroup() + +
+

Ceny, heatmapy

+
ggplot(rent) + geom_point(aes(x=city, y=price, col=centreDistance), alpha=0.1, size=0.5) + scale_color_viridis_c()
+

+
ggplot(rent_norm) + geom_point(aes(x=longitude_n, y=latitude_n, col=log(price)), alpha=0.01, size=0.2) + facet_wrap(~ city) + scale_color_viridis_c()
+

ggplot(rent[rent$city=="warszawa", ]) + geom_point(aes(x=longitude, y=latitude, col=log(price)), alpha=0.1, size=0.1) + scale_color_viridis_c()
-

-
ggplot(rent[rent$city=="gdansk", ]) + geom_point(aes(x=longitude, y=latitude, col=log(price)), alpha=0.1, size=0.5) + scale_color_viridis_c()
-

-
ggplot(rent[rent$city=="wroclaw", ]) + geom_point(aes(x=longitude, y=latitude, col=log(price)), alpha=0.1, size=0.5) + scale_color_viridis_c()
-

-
ggplot(rent[rent$city=="poznan", ]) + geom_point(aes(x=longitude, y=latitude, col=log(price)), alpha=0.1, size=0.5) + scale_color_viridis_c()
-

-
ggplot(rent, aes(x = rooms)) +
-  geom_histogram(aes(y = after_stat(density)), binwidth = 1, fill = "steelblue", color = "white") +
-  facet_wrap(~ city) +
-  theme_minimal()
-

+

+
+
+

Czy ceny normalne?

+
prices_overall <- rent$price
+lillie.test(prices_overall)
+
## 
+##  Lilliefors (Kolmogorov-Smirnov) normality test
+## 
+## data:  prices_overall
+## D = 0.18915, p-value < 2.2e-16
+
prices_warsaw <- rent[rent$city=="bialystok", ]$price
+lillie.test(prices_warsaw)
+
## 
+##  Lilliefors (Kolmogorov-Smirnov) normality test
+## 
+## data:  prices_warsaw
+## D = 0.089354, p-value = 5.716e-09
+
prices_without_warsaw <- rent[rent$city!="warszawa", ]$price
+lillie.test(prices_without_warsaw)
+
## 
+##  Lilliefors (Kolmogorov-Smirnov) normality test
+## 
+## data:  prices_without_warsaw
+## D = 0.15724, p-value < 2.2e-16
diff --git a/projekt.rmd b/projekt.rmd index e99ed1c..a3d5f7f 100644 --- a/projekt.rmd +++ b/projekt.rmd @@ -11,6 +11,9 @@ output: knitr::opts_chunk$set(echo = TRUE) library(dplyr) library(ggplot2) +library(nortest) +fig.width = 8 +fig.height = 5 ``` ### Data Fields @@ -32,7 +35,7 @@ library(ggplot2) apartments_rent_pl_YYYY_MM.csv: monthly rent -```{r import data, fig.width = 8, fig.height = 5} +```{r import data} files <- list.files("rent", pattern = "\\.csv$", full.names = TRUE) files <- sort(files) @@ -49,9 +52,6 @@ has_cols <- grep("^has", names(rent), value = TRUE) rent[has_cols] <- lapply(rent[has_cols], function(x) { tolower(x) == "yes" }) -summary(rent) - -ggplot(rent) + geom_point(aes(x=city, y=price, col=centreDistance), alpha=0.1, size=0.5) + scale_color_viridis_c() rent_norm <- rent %>% group_by(city) %>% @@ -62,17 +62,26 @@ rent_norm <- rent %>% ) %>% mutate() %>% ungroup() +``` + +# Ceny, heatmapy + +```{r heatmaps} +ggplot(rent) + geom_point(aes(x=city, y=price, col=centreDistance), alpha=0.1, size=0.5) + scale_color_viridis_c() ggplot(rent_norm) + geom_point(aes(x=longitude_n, y=latitude_n, col=log(price)), alpha=0.01, size=0.2) + facet_wrap(~ city) + scale_color_viridis_c() ggplot(rent[rent$city=="warszawa", ]) + geom_point(aes(x=longitude, y=latitude, col=log(price)), alpha=0.1, size=0.1) + scale_color_viridis_c() -ggplot(rent[rent$city=="gdansk", ]) + geom_point(aes(x=longitude, y=latitude, col=log(price)), alpha=0.1, size=0.5) + scale_color_viridis_c() -ggplot(rent[rent$city=="wroclaw", ]) + geom_point(aes(x=longitude, y=latitude, col=log(price)), alpha=0.1, size=0.5) + scale_color_viridis_c() -ggplot(rent[rent$city=="poznan", ]) + geom_point(aes(x=longitude, y=latitude, col=log(price)), alpha=0.1, size=0.5) + scale_color_viridis_c() - -ggplot(rent, aes(x = rooms)) + - geom_histogram(aes(y = after_stat(density)), binwidth = 1, fill = "steelblue", color = "white") + - facet_wrap(~ city) + - theme_minimal() - ``` + +# Czy ceny normalne? + +```{r isnormal} +prices_overall <- rent$price +lillie.test(prices_overall) +prices_warsaw <- rent[rent$city=="bialystok", ]$price +lillie.test(prices_warsaw) +prices_without_warsaw <- rent[rent$city!="warszawa", ]$price +lillie.test(prices_without_warsaw) +``` +