Preparation
raw_data <- read_xlsx("C:/Users/rabia/Desktop/bda 503/EVDS_istanbul_property_data.xlsx", n_max=130)
glimpse(raw_data)
## Rows: 129
## Columns: 9
## $ Tarih <chr> "2010-01", "2010-02", "2010-03", "2010-04",...
## $ `TP AKONUTSAT1 T40` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ `TP AKONUTSAT2 T40` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ `TP AKONUTSAT3 T40` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ `TP AKONUTSAT4 T40` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ `TP DISKONSAT ISTANBUL` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ `TP HEDONIKYKFE IST` <dbl> 35.9, 36.6, 37.4, 38.0, 38.0, 37.6, 37.3, 3...
## $ `TP HKFE02` <dbl> 36.0, 36.2, 36.5, 36.9, 37.1, 37.0, 37.2, 3...
## $ `TP TCBF02 ISTANBUL` <dbl> 1414.9, 1420.1, 1427.9, 1442.7, 1449.0, 144...
First, letโs convert date format to yyyy-mm-dd from yyyy-mm:
sub_data <- raw_data %>%
select(Tarih,'TP AKONUTSAT1 T40', 'TP DISKONSAT ISTANBUL') %>%
mutate(full_date = as.Date(paste0(Tarih,"-01")))
sub_data %>% glimpse()
## Rows: 129
## Columns: 4
## $ Tarih <chr> "2010-01", "2010-02", "2010-03", "2010-04",...
## $ `TP AKONUTSAT1 T40` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ `TP DISKONSAT ISTANBUL` <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ full_date <date> 2010-01-01, 2010-02-01, 2010-03-01, 2010-0...
plot1 <- sub_data %>%
group_by(year = lubridate::year(full_date)) %>%
summarise(mean_native_sales = mean(`TP AKONUTSAT1 T40`), mean_foreign_sales = mean(`TP DISKONSAT ISTANBUL`))