little data overview

This commit is contained in:
2026-05-04 23:27:54 +02:00
parent a3ec4c6ca0
commit a2a913f1e6
+41 -6
View File
@@ -50,13 +50,13 @@ files_apartments <- list.files("apartments", pattern = "\\.csv$", full.names = T
rent_list <- lapply(seq_along(files_rent), function(i) {
d <- read.csv(files_rent[i])
d$type = "rent"
d$offer_type = "rent"
d
})
apartments_list <- lapply(seq_along(files_apartments), function(i) {
d <- read.csv(files_apartments[i])
d$type = "apartment"
d$offer_type = "apartment"
d
})
@@ -82,7 +82,7 @@ df <- df %>%
longitude_n = as.numeric(scale(longitude))
) %>%
ungroup() %>%
group_by(type) %>%
group_by(offer_type) %>%
mutate(
price_n = as.numeric(scale(price)),
price_m2_n = as.numeric(scale(price_m2)),
@@ -91,10 +91,45 @@ df <- df %>%
) %>%
ungroup()
rent <- df[df$type == "rent",]
rent <- df[df$offer_type == "rent",]
rent_warsaw <- rent[rent$city == "warszawa",]
apartments <- df[df$type == "apartment",]
apartments <- df[df$offer_type == "apartment",]
apartments_warsaw <- apartments[apartments$city == "warszawa",]
df_city <- df %>%
count(city) %>%
mutate(
perc = n / sum(n) * 100,
label = paste0(round(perc, 1), "%")
)
rent_city <- rent %>%
group_by(city) %>%
summarise(mean_price_m2 = mean(price_m2, na.rm = TRUE))
ggplot(df_city, aes(x = reorder(city, -perc), y = perc)) +
geom_col(fill = "steelblue") +
geom_text(aes(label = paste0(round(perc, 1), "%")),
vjust = -0.3, size = 3) +
labs(
title = "Procent mieszkań według miasta",
x = "Miasto",
y = "Procent"
) +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
ggplot(rent_city, aes(x = reorder(city, mean_price_m2),
y = mean_price_m2)) +
geom_col(fill = "steelblue") +
coord_flip() +
labs(
title = "Średnia cena m² wg miasta",
x = "Miasto",
y = "Średnia cena m²"
) +
theme_minimal()
```
# Wykresy
@@ -244,7 +279,7 @@ ggplot(df, aes(x = log_price_m2_n)) +
bins = 50,
fill = "lightblue",
color = "white") +
facet_wrap(~ type)
facet_wrap(~ offer_type)
qqnorm(rent$log_price_m2_n)
qqline(rent$log_price_m2_n, col = "red")