little data overview
This commit is contained in:
+41
-6
@@ -50,13 +50,13 @@ files_apartments <- list.files("apartments", pattern = "\\.csv$", full.names = T
|
|||||||
|
|
||||||
rent_list <- lapply(seq_along(files_rent), function(i) {
|
rent_list <- lapply(seq_along(files_rent), function(i) {
|
||||||
d <- read.csv(files_rent[i])
|
d <- read.csv(files_rent[i])
|
||||||
d$type = "rent"
|
d$offer_type = "rent"
|
||||||
d
|
d
|
||||||
})
|
})
|
||||||
|
|
||||||
apartments_list <- lapply(seq_along(files_apartments), function(i) {
|
apartments_list <- lapply(seq_along(files_apartments), function(i) {
|
||||||
d <- read.csv(files_apartments[i])
|
d <- read.csv(files_apartments[i])
|
||||||
d$type = "apartment"
|
d$offer_type = "apartment"
|
||||||
d
|
d
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ df <- df %>%
|
|||||||
longitude_n = as.numeric(scale(longitude))
|
longitude_n = as.numeric(scale(longitude))
|
||||||
) %>%
|
) %>%
|
||||||
ungroup() %>%
|
ungroup() %>%
|
||||||
group_by(type) %>%
|
group_by(offer_type) %>%
|
||||||
mutate(
|
mutate(
|
||||||
price_n = as.numeric(scale(price)),
|
price_n = as.numeric(scale(price)),
|
||||||
price_m2_n = as.numeric(scale(price_m2)),
|
price_m2_n = as.numeric(scale(price_m2)),
|
||||||
@@ -91,10 +91,45 @@ df <- df %>%
|
|||||||
) %>%
|
) %>%
|
||||||
ungroup()
|
ungroup()
|
||||||
|
|
||||||
rent <- df[df$type == "rent",]
|
rent <- df[df$offer_type == "rent",]
|
||||||
rent_warsaw <- rent[rent$city == "warszawa",]
|
rent_warsaw <- rent[rent$city == "warszawa",]
|
||||||
apartments <- df[df$type == "apartment",]
|
apartments <- df[df$offer_type == "apartment",]
|
||||||
apartments_warsaw <- apartments[apartments$city == "warszawa",]
|
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
|
# Wykresy
|
||||||
@@ -244,7 +279,7 @@ ggplot(df, aes(x = log_price_m2_n)) +
|
|||||||
bins = 50,
|
bins = 50,
|
||||||
fill = "lightblue",
|
fill = "lightblue",
|
||||||
color = "white") +
|
color = "white") +
|
||||||
facet_wrap(~ type)
|
facet_wrap(~ offer_type)
|
||||||
|
|
||||||
qqnorm(rent$log_price_m2_n)
|
qqnorm(rent$log_price_m2_n)
|
||||||
qqline(rent$log_price_m2_n, col = "red")
|
qqline(rent$log_price_m2_n, col = "red")
|
||||||
|
|||||||
Reference in New Issue
Block a user