wstępna analiza, parsowanie danych

This commit is contained in:
2026-04-29 15:30:08 +02:00
parent b452b56501
commit 5959cfbc75
3 changed files with 192 additions and 41 deletions

No files matched your search

+133 -25
View File
File diff suppressed because one or more lines are too long
BIN
View File
Binary file not shown.
+59 -16
View File
@@ -2,29 +2,72 @@
title: "Projekt Zaliczeniowy 1"
author: "Michał Hiszpański, Nikola Kubiczek, Adrian Mirecki"
date: "2026-04-29"
output: html_document
output:
html_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(dplyr)
library(ggplot2)
```
## R Markdown
### Data Fields
1. ```city``` - the name of the city where the property is located
1. ```type``` - type of the building
1. ```squareMeters``` - the size of the apartment in square meters
1. ```rooms``` - number of rooms in the apartment
1. ```floor``` / floorCount - the floor where the apartment is located and the total number of floors in the building
1. ```buildYear``` - the year when the building was built
1. ```latitude```, ```longitude``` - geo coordinate of the property
1. ```centreDistance``` - distance from the city centre in km
1. ```poiCount``` - number of points of interest in 500m range from the apartment (schools, clinics, post offices, kindergartens, restaurants, colleges, pharmacies)
1. ```[poiName]Distance``` - distance to the nearest point of interest (schools, clinics, post offices, kindergartens, restaurants, colleges, pharmacies)
1. ```ownership``` - the type of property ownership
1. ```condition``` - the condition of the apartment
1. ```has[features]``` - whether the property has key features such as assigned parking space, balcony, elevator, security, storage room
1. ```price``` - offer price in Polish Zloty
apartments_pl_YYYY_MM.csv: sale price
apartments_rent_pl_YYYY_MM.csv: monthly rent
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r import data, fig.width = 8, fig.height = 5}
files <- list.files("rent", pattern = "\\.csv$", full.names = TRUE)
files <- sort(files)
df_list <- lapply(seq_along(files), function(i) {
d <- read.csv(files[i])
d$month_id <- i
d
})
rent <- do.call(rbind, df_list)
has_cols <- grep("^has", names(rent), value = TRUE)
rent[has_cols] <- lapply(rent[has_cols], function(x) {
tolower(x) == "yes"
})
summary(rent)
rent_norm <- rent %>%
group_by(city) %>%
mutate(
latitude_n = as.numeric(scale(latitude)),
longitude_n = as.numeric(scale(longitude)),
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()
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=="krakow", ]) + 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()
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.