library(readr)
library(dplyr)
library(tidyr)
library(magrittr)
library(Hmisc)
library(forecast)
library(stringr)
library(lubridate)
library(editrules)
Two open data sets accidents
and weather
were joined to create the data frame used for required data preprocessing. Some tidying of the data sets occured before merging. They were filtered to keep only observations for January 2016 to reduce the number of rows as well as the running time. The key
variable was created to enable merging the data frames with left join()
. Types of variables, data structures and attributes were checked. Data types conversions were performed where necessary. The combined
data frame conforms the tidy data principles, so not much was done to tidy it up. Two new variables were mutated from the existing for better understanding of data. Scanning the data for missing values, inconsistencies and obvious errors was performed. Missing values in some numeric variables were removed due to their nature and some were replaced with a mean value. No data inconsistency was found. The numeric variables were scanned for univariate outliers. In some cases the outliers were kept and in some - capped using the Tukey’s method. Data transformation techniques were applied where seemed appropriate.
The accidents
data set contains 477732 observations of 29 variables and includes the information about all vehicle collisions in New York City during 2015 and 2016. It was taken from kaggle.com located at https://www.kaggle.com/nypd/vehicle-collisions/home.
The variables are: UNIQUE KEY
[integer], DATE
[character], TIME
[‘hms’ numeric], BOROUGH
[character], ZIP CODE
[integer], LATITUDE
[numeric], LONGITUDE
[numeric], LOCATION
[character], ON STREET NAME
[character], CROSS STREET NAME
[character], OFF STREET NAME
[character], PERSONS INJURED
[integer], PERSONS KILLED
[integer], PEDESTRIANS INJURED
[integer], PEDESTRIANS KILLED
[integer], CYCLISTS INJURED
[integer], CYCLISTS KILLED
[integer], MOTORISTS INJURED
[integer], MOTORISTS KILLED
[integer], VEHICLE 1 TYPE
[character], VEHICLE 2 TYPE
[character], VEHICLE 3 TYPE
[character], VEHICLE 4 TYPE
[character],VEHICLE 5 TYPE
[character], VEHICLE 1 FACTOR
[character], VEHICLE 2 FACTOR
[character], VEHICLE 3 FACTOR
[character], VEHICLE 4 FACTOR
[character], VEHICLE 5 FACTOR
[character]. Variables like VEHICLE FACTOR
refer to the reason this vehicle was involved in an accident. The other variables are self explanatory.
The weather
data set contains 5175 observations of 12 variables and includes the information about hourly weather conditions in New York City from January to June 2016. It was taken from kaggle.com located at https://www.kaggle.com/pschale/nyc-taxi-wunderground-weather/home.
The variables are: timestamp
[POSIXct], temp
[numeric], windspeed
[numeric], humidity
[numeric], precip
[numeric], pressure
[numeric], conditions
[character], dailyprecip
[character], dailysnow
[character], fog
[integer], rain
[integer], snow
[integer]. precip
and dailyprecip
variables refer to precipitation during last hour in inches and the total precipitation during the day respectively. Variables fog
, rain
and snow
: if 1 - current conditions include fog, rain or snow, else 0. The other variables are self explanatory.
accidents <- read_csv("accidents.csv")
Parsed with column specification:
cols(
.default = col_character(),
`UNIQUE KEY` = col_integer(),
TIME = col_time(format = ""),
`ZIP CODE` = col_integer(),
LATITUDE = col_double(),
LONGITUDE = col_double(),
`PERSONS INJURED` = col_integer(),
`PERSONS KILLED` = col_integer(),
`PEDESTRIANS INJURED` = col_integer(),
`PEDESTRIANS KILLED` = col_integer(),
`CYCLISTS INJURED` = col_integer(),
`CYCLISTS KILLED` = col_integer(),
`MOTORISTS INJURED` = col_integer(),
`MOTORISTS KILLED` = col_integer()
)
See spec(...) for full column specifications.
head(accidents)
weather <- read_csv("weatherdata.csv")
Parsed with column specification:
cols(
timestamp = col_datetime(format = ""),
temp = col_double(),
windspeed = col_double(),
humidity = col_double(),
precip = col_double(),
pressure = col_double(),
conditions = col_character(),
dailyprecip = col_character(),
dailysnow = col_character(),
fog = col_integer(),
rain = col_integer(),
snow = col_integer()
)
head(weather)
accidents$DATE <- mdy(accidents$DATE)
accidents <- accidents %>% mutate(., year = year(accidents$DATE),
month = month(accidents$DATE),
day = day(accidents$DATE),
hour = hour(accidents$TIME))
accidents <- accidents %>% filter(., year == 2016 & month == 1)
accidents <- accidents %>% unite(key, month, day, hour, sep = "-")
accidents <- accidents[c(1:3, 5, 12:19, 31)]
head(accidents)
weather <- weather %>% mutate(month = month(timestamp),
day = day(timestamp),
hour = hour(timestamp))
weather <- weather %>% filter(., month == 1)
weather <- weather %>% unite(key, month, day, hour, sep = "-")
tidy_weather <- weather %>% filter(., minute(timestamp) == 51)
head(tidy_weather)
combined <- left_join(accidents, tidy_weather, by = "key")
head(combined)
accidents
and weather
data sets were joined to create a combined
data frame which was used for further processing. Left join was used to match the observations from the weather
data frame to the accidents
data frame and keep all observations in the latter. Key variable key
was mutated to merge the data sets, it was created by uniting month number, day of the month and hour.
Some tidying of the initial data sets was performed before they were merged. The steps were as follows:
DATE
variable was converted from character to a date type with the use of mdy()
function.
Four additional variables were created (year
, month
, day
, hour
) by extracting elements from the DATE
and TIME
variables.
The accidents
data frame was filtered to keep only observations for January 2016, the same was done to the weather
data frame. The accidents
data was also subset to keep only required variables.
After analysing the weather
data frame, it was found that it contained several observations for the same hour in the day which created duplicates when joined to accidents
data. So, only observations for 51st minute of every hour in a day were kept in a tidy_weather
data frame (e.g. 2016-01-01 00:51:00, 2016-01-01 01:51:00, etc.), as this was an hourly pattern in the data.
After all tidying and filtering, the combined
data frame contains 18101 observations of 25 variables.
combined <- combined %>% mutate(., `UNIQUE KEY` = as.character(`UNIQUE KEY`),
`ZIP CODE` = as.character(`ZIP CODE`))
combined$dailyprecip[which(combined$dailyprecip == "T")] <- "0.00"
combined$dailysnow[which(combined$dailysnow == "T")] <- "0.00"
combined <- combined %>% mutate(precip = as.numeric(precip),
dailyprecip = as.numeric(dailyprecip),
dailysnow = as.numeric(dailysnow))
combined <- combined %>% mutate(fog = factor(fog, levels = c("0","1"), labels = c("No","Yes")),
rain = factor(rain, levels = c("0","1"), labels = c("No","Yes")),
snow = factor(snow, levels = c("0","1"), labels = c("No","Yes")))
head(combined$fog)
[1] No No No No No No
Levels: No Yes
head(combined$rain)
[1] No No No No No No
Levels: No Yes
head(combined$snow)
[1] No No No No No No
Levels: No Yes
str(combined)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 18101 obs. of 25 variables:
$ UNIQUE KEY : chr "3374565" "3511927" "3363408" "3364610" ...
$ DATE : Date, format: "2016-01-01" ...
$ TIME : 'hms' num 00:01:00 00:01:00 00:01:00 00:05:00 ...
..- attr(*, "units")= chr "secs"
$ ZIP CODE : chr "10022" "11235" "10035" "10035" ...
$ PERSONS INJURED : int 0 1 1 2 0 0 0 0 0 1 ...
$ PERSONS KILLED : int 0 0 0 0 0 0 0 0 0 0 ...
$ PEDESTRIANS INJURED: int 0 0 1 0 0 0 0 0 0 1 ...
$ PEDESTRIANS KILLED : int 0 0 0 0 0 0 0 0 0 0 ...
$ CYCLISTS INJURED : int 0 3 0 0 0 0 0 0 0 0 ...
$ CYCLISTS KILLED : int 0 0 0 0 0 0 0 0 0 0 ...
$ MOTORISTS INJURED : int 0 0 0 2 0 0 0 0 0 0 ...
$ MOTORISTS KILLED : int 0 0 0 0 0 0 0 0 0 0 ...
$ key : chr "1-1-0" "1-1-0" "1-1-0" "1-1-0" ...
$ timestamp : POSIXct, format: "2016-01-01 00:51:00" ...
$ temp : num 42.1 42.1 42.1 42.1 42.1 42.1 42.1 42.1 42.1 42.1 ...
$ windspeed : num 4.6 4.6 4.6 4.6 4.6 4.6 4.6 4.6 4.6 4.6 ...
$ humidity : num 51 51 51 51 51 51 51 51 51 51 ...
$ precip : num 0 0 0 0 0 0 0 0 0 0 ...
$ pressure : num 30.1 30.1 30.1 30.1 30.1 ...
$ conditions : chr "Overcast" "Overcast" "Overcast" "Overcast" ...
$ dailyprecip : num 0 0 0 0 0 0 0 0 0 0 ...
$ dailysnow : num 0 0 0 0 0 0 0 0 0 0 ...
$ fog : Factor w/ 2 levels "No","Yes": 1 1 1 1 1 1 1 1 1 1 ...
$ rain : Factor w/ 2 levels "No","Yes": 1 1 1 1 1 1 1 1 1 1 ...
$ snow : Factor w/ 2 levels "No","Yes": 1 1 1 1 1 1 1 1 1 1 ...
attributes(combined)
$names
[1] "UNIQUE KEY" "DATE"
[3] "TIME" "ZIP CODE"
[5] "PERSONS INJURED" "PERSONS KILLED"
[7] "PEDESTRIANS INJURED" "PEDESTRIANS KILLED"
[9] "CYCLISTS INJURED" "CYCLISTS KILLED"
[11] "MOTORISTS INJURED" "MOTORISTS KILLED"
[13] "key" "timestamp"
[15] "temp" "windspeed"
[17] "humidity" "precip"
[19] "pressure" "conditions"
[21] "dailyprecip" "dailysnow"
[23] "fog" "rain"
[25] "snow"
$class
[1] "tbl_df" "tbl" "data.frame"
$row.names
[1] 1 2 3 4 5 6 7 8 9 10 11 12
[13] 13 14 15 16 17 18 19 20 21 22 23 24
[25] 25 26 27 28 29 30 31 32 33 34 35 36
[37] 37 38 39 40 41 42 43 44 45 46 47 48
[49] 49 50 51 52 53 54 55 56 57 58 59 60
[61] 61 62 63 64 65 66 67 68 69 70 71 72
[73] 73 74 75 76 77 78 79 80 81 82 83 84
[85] 85 86 87 88 89 90 91 92 93 94 95 96
[97] 97 98 99 100 101 102 103 104 105 106 107 108
[109] 109 110 111 112 113 114 115 116 117 118 119 120
[121] 121 122 123 124 125 126 127 128 129 130 131 132
[133] 133 134 135 136 137 138 139 140 141 142 143 144
[145] 145 146 147 148 149 150 151 152 153 154 155 156
[157] 157 158 159 160 161 162 163 164 165 166 167 168
[169] 169 170 171 172 173 174 175 176 177 178 179 180
[181] 181 182 183 184 185 186 187 188 189 190 191 192
[193] 193 194 195 196 197 198 199 200 201 202 203 204
[205] 205 206 207 208 209 210 211 212 213 214 215 216
[217] 217 218 219 220 221 222 223 224 225 226 227 228
[229] 229 230 231 232 233 234 235 236 237 238 239 240
[241] 241 242 243 244 245 246 247 248 249 250 251 252
[253] 253 254 255 256 257 258 259 260 261 262 263 264
[265] 265 266 267 268 269 270 271 272 273 274 275 276
[277] 277 278 279 280 281 282 283 284 285 286 287 288
[289] 289 290 291 292 293 294 295 296 297 298 299 300
[301] 301 302 303 304 305 306 307 308 309 310 311 312
[313] 313 314 315 316 317 318 319 320 321 322 323 324
[325] 325 326 327 328 329 330 331 332 333 334 335 336
[337] 337 338 339 340 341 342 343 344 345 346 347 348
[349] 349 350 351 352 353 354 355 356 357 358 359 360
[361] 361 362 363 364 365 366 367 368 369 370 371 372
[373] 373 374 375 376 377 378 379 380 381 382 383 384
[385] 385 386 387 388 389 390 391 392 393 394 395 396
[397] 397 398 399 400 401 402 403 404 405 406 407 408
[409] 409 410 411 412 413 414 415 416 417 418 419 420
[421] 421 422 423 424 425 426 427 428 429 430 431 432
[433] 433 434 435 436 437 438 439 440 441 442 443 444
[445] 445 446 447 448 449 450 451 452 453 454 455 456
[457] 457 458 459 460 461 462 463 464 465 466 467 468
[469] 469 470 471 472 473 474 475 476 477 478 479 480
[481] 481 482 483 484 485 486 487 488 489 490 491 492
[493] 493 494 495 496 497 498 499 500 501 502 503 504
[505] 505 506 507 508 509 510 511 512 513 514 515 516
[517] 517 518 519 520 521 522 523 524 525 526 527 528
[529] 529 530 531 532 533 534 535 536 537 538 539 540
[541] 541 542 543 544 545 546 547 548 549 550 551 552
[553] 553 554 555 556 557 558 559 560 561 562 563 564
[565] 565 566 567 568 569 570 571 572 573 574 575 576
[577] 577 578 579 580 581 582 583 584 585 586 587 588
[589] 589 590 591 592 593 594 595 596 597 598 599 600
[601] 601 602 603 604 605 606 607 608 609 610 611 612
[613] 613 614 615 616 617 618 619 620 621 622 623 624
[625] 625 626 627 628 629 630 631 632 633 634 635 636
[637] 637 638 639 640 641 642 643 644 645 646 647 648
[649] 649 650 651 652 653 654 655 656 657 658 659 660
[661] 661 662 663 664 665 666 667 668 669 670 671 672
[673] 673 674 675 676 677 678 679 680 681 682 683 684
[685] 685 686 687 688 689 690 691 692 693 694 695 696
[697] 697 698 699 700 701 702 703 704 705 706 707 708
[709] 709 710 711 712 713 714 715 716 717 718 719 720
[721] 721 722 723 724 725 726 727 728 729 730 731 732
[733] 733 734 735 736 737 738 739 740 741 742 743 744
[745] 745 746 747 748 749 750 751 752 753 754 755 756
[757] 757 758 759 760 761 762 763 764 765 766 767 768
[769] 769 770 771 772 773 774 775 776 777 778 779 780
[781] 781 782 783 784 785 786 787 788 789 790 791 792
[793] 793 794 795 796 797 798 799 800 801 802 803 804
[805] 805 806 807 808 809 810 811 812 813 814 815 816
[817] 817 818 819 820 821 822 823 824 825 826 827 828
[829] 829 830 831 832 833 834 835 836 837 838 839 840
[841] 841 842 843 844 845 846 847 848 849 850 851 852
[853] 853 854 855 856 857 858 859 860 861 862 863 864
[865] 865 866 867 868 869 870 871 872 873 874 875 876
[877] 877 878 879 880 881 882 883 884 885 886 887 888
[889] 889 890 891 892 893 894 895 896 897 898 899 900
[901] 901 902 903 904 905 906 907 908 909 910 911 912
[913] 913 914 915 916 917 918 919 920 921 922 923 924
[925] 925 926 927 928 929 930 931 932 933 934 935 936
[937] 937 938 939 940 941 942 943 944 945 946 947 948
[949] 949 950 951 952 953 954 955 956 957 958 959 960
[961] 961 962 963 964 965 966 967 968 969 970 971 972
[973] 973 974 975 976 977 978 979 980 981 982 983 984
[985] 985 986 987 988 989 990 991 992 993 994 995 996
[997] 997 998 999 1000
[ reached getOption("max.print") -- omitted 17101 entries ]
The steps taken in this section:
Integer variables UNIQUE KEY
and ZIP CODE
were converted to a character type.
Variables dailyprecip
and dailysnow
were read as characters because of, what seems to be, a data entry error, they had an unexplainable “T” character in several observations. They was replaced with a 0.00 value. These variables, as well as the variable precip
, were converted to a numeric type.
Integer variables fog
, rain
and snow
were converted to factors and labeled.
Structure and attributes of combined
data frame were checked.
In this section DATE
and TIME
variables from combined
data frame were united to create a DATETIME
varible. DATETIME
was converted to a date(POSIXct) type. Overall, as some tidying up has been done before joining data sets, merged data conforms the tidy data principles (each variable forms a column, each observation forms a row and each type of observational unit forms a table).
combined <- combined %>% unite(DATETIME,DATE,TIME, sep = " ")
combined$DATETIME <- ymd_hms(combined$DATETIME)
head(combined)
Two new variables PEOPLE_INJURED
and PEOPLE_KILLED
were created from the existing variables for better understanding of the data. Subset was done to drop the unnecessary columns.
combined <- combined %>% mutate(`PEOPLE_INJURED` = `PERSONS INJURED`+`PEDESTRIANS INJURED`+`CYCLISTS INJURED`+`MOTORISTS INJURED`,
`PEOPLE_KILLED` = `PERSONS KILLED`+`PEDESTRIANS KILLED`+`CYCLISTS KILLED`+`MOTORISTS KILLED`)
combined_1 <- combined[,-(4:13)]
head(combined_1)
The steps taken in this section are as follows:
The combined_1
data frame was scanned for missing values using functions colSums(is.na())
. Only missing values in numeric variables were considered.
Based on the output of the previous step, it was found variables temp
, humidity
, precip
, conditions
, dailypercip
, dailysnow
, fog
, rain
and snow
have the same number of missing values. After checking the locations of these missing values, it was found they occured in the same observations. These missing values, therefore, were introduced in the process of left_join()
.
The missing values mentioned above were removed by subsetting.
There were also missing values in varaibles windspeed
and pressure
, they were replaced with the mean value.
Lastly, inconsisitencies were checked using violatedEdits()
under the rule we set, and no violations were found in the data set.
colSums(is.na(combined_1))
UNIQUE KEY DATETIME ZIP CODE temp
0 0 4148 77
windspeed humidity precip pressure
2859 77 77 336
conditions dailyprecip dailysnow fog
77 77 77 77
rain snow PEOPLE_INJURED PEOPLE_KILLED
77 77 0 0
which(is.na(combined_1$humidity))
[1] 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722
[14] 1723 1724 1725 1726 1727 1728 1852 1853 1854 1855 1856 1857 1858
[27] 1859 1860 1861 1862 1863 2262 2263 4178 4179 4180 4181 4182 4183
[40] 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196
[53] 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209
[66] 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221
which(is.na(combined_1$dailyprecip))
[1] 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722
[14] 1723 1724 1725 1726 1727 1728 1852 1853 1854 1855 1856 1857 1858
[27] 1859 1860 1861 1862 1863 2262 2263 4178 4179 4180 4181 4182 4183
[40] 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196
[53] 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209
[66] 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221
which(is.na(combined_1$temp))
[1] 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722
[14] 1723 1724 1725 1726 1727 1728 1852 1853 1854 1855 1856 1857 1858
[27] 1859 1860 1861 1862 1863 2262 2263 4178 4179 4180 4181 4182 4183
[40] 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196
[53] 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209
[66] 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221
combined_2 <- combined_1[-(which(is.na(combined_1$temp))),]
colSums(is.na(combined_2))
UNIQUE KEY DATETIME ZIP CODE temp
0 0 4131 0
windspeed humidity precip pressure
2782 0 0 259
conditions dailyprecip dailysnow fog
0 0 0 0
rain snow PEOPLE_INJURED PEOPLE_KILLED
0 0 0 0
combined_2$windspeed[is.na(combined_2$windspeed)] <- mean(combined_2$windspeed, na.rm = T)
combined_2$pressure[is.na(combined_2$pressure)] <- mean(combined_2$pressure, na.rm = T)
colSums(is.na(combined_2))
UNIQUE KEY DATETIME ZIP CODE temp
0 0 4131 0
windspeed humidity precip pressure
0 0 0 0
conditions dailyprecip dailysnow fog
0 0 0 0
rain snow PEOPLE_INJURED PEOPLE_KILLED
0 0 0 0
(rule1 <- editset(c("windspeed >= 0", "humidity >= 0", "humidity <= 100", "precip >= 0", "pressure >=0", "dailyprecip >= 0", "dailysnow >= 0", "PEOPLE_INJURED >= 0", "PEOPLE_KILLED >=0")))
Edit set:
num1 : 0 <= windspeed
num2 : 0 <= humidity
num3 : humidity <= 100
num4 : 0 <= precip
num5 : 0 <= pressure
num6 : 0 <= dailyprecip
num7 : 0 <= dailysnow
num8 : 0 <= PEOPLE_INJURED
num9 : 0 <= PEOPLE_KILLED
violated <- violatedEdits(rule1, combined_2)
summary(violated)
No violations detected, 0 checks evaluated to NA
NULL
The steps taken in this section are as follows:
Boxplot of numeric variables were created side by side for scanning univariate ourliers.
Outliers in variables windspeed
, humidity
and pressure
were capped using the Tukey’s method.
Outliers in variables precip
, dailyprecip
, dailysnow
, PEOPLE INJURED
and PEOPLE KILLED
were kept, they occur only because most of the observations in these variables are zeros.
Boxplots of the capped variables were made to check if capping successfully removed the outliers.
par(mfrow=c(2,5))
combined_2$temp %>% boxplot(main = "Temperature")
combined_2$windspeed %>% boxplot(main = "Windspeed")
combined_2$humidity %>% boxplot(main = "Humidity")
combined_2$precip %>% boxplot(main = "Precipitation")
combined_2$pressure %>% boxplot(main = "Pressure")
combined_2$dailyprecip %>% boxplot(main = "Daily Precipitation")
combined_2$dailysnow %>% boxplot(main = "Daily Snow")
combined_2$PEOPLE_INJURED %>% boxplot(main = "People Injured")
combined_2$PEOPLE_KILLED %>% boxplot(main = "People Killed")
cap <- function(x){
quantiles <- quantile( x, c(.05, 0.25, 0.75, .95 ) )
x[ x < quantiles[2] - 1.5*IQR(x) ] <- quantiles[1]
x[ x > quantiles[3] + 1.5*IQR(x) ] <- quantiles[4]
x
}
combined_2$windspeed <- combined_2$windspeed %>% cap()
combined_2$humidity <- combined_2$humidity %>% cap()
combined_2$pressure <- combined_2$pressure %>% cap()
par(mfrow=c(1,3))
combined_2$windspeed %>% boxplot(main = "Windspeed")
combined_2$humidity %>% boxplot(main = "Humidity")
combined_2$pressure %>% boxplot(main = "Pressure")
In this section square root transformation was applied for the windspeed
variable to reduce slight right skewness in its distribution. Histograms were made to visualise the effect of data transformation.
Z-score transformation was applied for variables humidity
and temp
, as their values have significantly greater range than the other variables. The resulting transformed data values have a zero mean and standard deviation equals to one.
transformed <- combined_2
hist(combined_2$windspeed,
breaks = 5,
main = "Histogram of Windspeed",
xlab = "Windspeed")
transformed$windspeed <- sqrt(combined_2$windspeed)
hist(transformed$windspeed, breaks = 5,
main = "Histogram of Transformed Windspeed",
xlab = "Square Root of Windspeed")
hist(combined_2$humidity,
main = "Histogram of Humidity",
xlab = "Humidity")
transformed$humidity <- scale(combined_2$humidity, center = T, scale = T)
hist(transformed$humidity,
main = "Histogram of Standardised Humidity",
xlab = "z-score Humidity")
hist(combined_2$temp,
main = "Histogram of Temperature",
xlab = "Temperature")
transformed$temp <- scale(combined_2$temp, center = T, scale = T)
hist(transformed$temp,
main = "Histogram of Standardised Temperature",
xlab = "z-score Temperature")
head(combined_2)
head(transformed)