library(ggplot2)
library(ggcorrplot)
library(tidyverse)
library(tidyr)
library(dplyr)
library(readr)
apartment <- read_csv("apartment.csv")
apartment$Bedroom <- as.factor(apartment$Bedroom)
apartment
## # A tibble: 5,147 x 34
## Bedroom Bathroom Locality Region Longitude Latitude Furnished Area AC
## <fct> <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 1 Semanggi Jakarta~ 107. -6.23 1 43 1
## 2 2 1 Kebon Jer~ Jakarta~ 107. -6.19 0 35 1
## 3 2 1 Kedoya Jakarta~ 107. -6.19 1 53 1
## 4 2 2 Pondok In~ Jakarta~ 107. -6.27 1 85 1
## 5 2 1 Grogol Jakarta~ 107. -6.15 0 48 1
## 6 2 1 Cempaka P~ Jakarta~ 107. -6.19 1 33 1
## 7 2 1 Kemayoran Jakarta~ 107. -6.15 1 58 1
## 8 3 2 Kemang Jakarta~ 107. -6.26 1 132 1
## 9 2 1 Pancoran Jakarta~ 107. -6.26 1 33 1
## 10 2 1 Cempaka P~ Jakarta~ 107. -6.19 0 33 1
## # ... with 5,137 more rows, and 25 more variables: Water_Heater <dbl>,
## # Dining_Set <dbl>, Electricity <dbl>, Bed <dbl>, Access_Card <dbl>,
## # Kitchen <dbl>, Fridge <dbl>, Washing_Machine <dbl>, TV <dbl>, ATM <dbl>,
## # TV_Cable <dbl>, Grocery <dbl>, Internet <dbl>, Swim_Pool <dbl>,
## # Laundry <dbl>, Security <dbl>, Basketball <dbl>, Multipurpose_Room <dbl>,
## # Gym <dbl>, Jogging <dbl>, Tennis <dbl>, Restaurant <dbl>, Playground <dbl>,
## # Total_Facilities <dbl>, AnnualPrice <dbl>
ggplot(apartment, aes(x=Area,
y=AnnualPrice,
color=Bedroom))+
geom_point(size=2,
alpha= .5)+
facet_wrap(~Bedroom, ncol = 5)+
labs(title="Annual Price of Apartments by Area and Number of Bedrooms",
subtitle="Jabodetabek Region",
x="Area (m2)",
y="Annual Price")+
scale_color_manual(values = c("Magenta","Yellow","Red","turquoise","Navy"))+
scale_y_continuous(labels = scales::unit_format(prefix="Rp",unit=""))+
scale_x_continuous(labels = scales::math_format(expr=.x^2),expression(Area(m^2)))+
theme_minimal()+
theme(plot.title = element_text(hjust=0.5),
plot.subtitle = element_text(hjust=0.5),
axis.title = element_text(size=15),
axis.text.x = element_text(angle=45))
ggplot(apartment,
aes(x=Bedroom,
y=AnnualPrice))+
labs(title = "Annual Price of Apartments by Number of Bedrooms",
subtitle = "Jabodetabek Region",
x = "Number of Bedrooms",
y = "Annual Price")+
geom_violin(fill="magenta")+
geom_boxplot(width= .5,
alpha=.6,
fill="grey")+
scale_y_continuous(labels = scales::unit_format(prefix = "Rp",unit = ""))+
theme_minimal()+
theme(plot.title = element_text(hjust=.5),
plot.subtitle = element_text(hjust=.5))
3.Correlationplot Apartment Features
apartmentNew<-apartment%>%
select(Area, Furnished, Playground, ATM, Security, Laundry, Multipurpose_Room, Jogging)
apartmentNew<-cor(apartmentNew, use = "complete.obs")
round(apartmentNew,2)
## Area Furnished Playground ATM Security Laundry
## Area 1.00 0.07 0.11 0.12 0.07 0.07
## Furnished 0.07 1.00 0.01 0.13 0.14 0.13
## Playground 0.11 0.01 1.00 0.50 0.11 0.34
## ATM 0.12 0.13 0.50 1.00 0.65 0.70
## Security 0.07 0.14 0.11 0.65 1.00 0.63
## Laundry 0.07 0.13 0.34 0.70 0.63 1.00
## Multipurpose_Room 0.12 0.06 0.39 0.63 0.62 0.67
## Jogging 0.13 0.04 0.12 0.06 0.06 0.07
## Multipurpose_Room Jogging
## Area 0.12 0.13
## Furnished 0.06 0.04
## Playground 0.39 0.12
## ATM 0.63 0.06
## Security 0.62 0.06
## Laundry 0.67 0.07
## Multipurpose_Room 1.00 0.06
## Jogging 0.06 1.00
ggcorrplot(apartmentNew,
title = "Apartment Features and Their Correlation ",
hc.order = TRUE,
#type = "lower",
lab = TRUE,
ggtheme = theme_grey(),
colors = c("Red","yellow","navy"))
ggplot(apartment,
aes(x=AnnualPrice,
y=reorder(Region, AnnualPrice),
color=Region))+
labs(title = "The Annual Price of Apartments in Different Regions",
subtitle="Jabodetabek Region",
x="Annual Price",
y="Region")+
geom_jitter(size=1.5)+
scale_x_continuous(labels = scales::unit_format(prefix = "Rp",unit = ""))+
theme_minimal()+
theme(plot.title = element_text(hjust=.5),
plot.subtitle = element_text(hjust=.5),
axis.title = element_text(size=15),
legend.position = "none")