library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.0.5
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 4.0.5
library(lubridate)
## Warning: package 'lubridate' was built under R version 4.0.5
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.0.5
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyr)
## Warning: package 'tidyr' was built under R version 4.0.5
library(DT)
## Warning: package 'DT' was built under R version 4.0.5
library(scales)
## Warning: package 'scales' was built under R version 4.0.5
library(ggthemes)
library(readxl)
## Warning: package 'readxl' was built under R version 4.0.5
data1 <- read.csv("C:\\Users\\tariqm\\Documents\\R\\Datasets\\uber-raw-data-apr14.csv")
data2 <- read.csv("C:\\Users\\tariqm\\Documents\\R\\Datasets\\uber-raw-data-may14.csv")
data3 <- read.csv("C:\\Users\\tariqm\\Documents\\R\\Datasets\\uber-raw-data-jun14.csv")
data4 <- read.csv("C:\\Users\\tariqm\\Documents\\R\\Datasets\\uber-raw-data-jul14.csv")
data5 <- read.csv("C:\\Users\\tariqm\\Documents\\R\\Datasets\\uber-raw-data-aug14.csv")
data6 <- read.csv("C:\\Users\\tariqm\\Documents\\R\\Datasets\\uber-raw-data-sep14.csv")
data_2014 <- rbind(data1,data2, data3, data4, data5, data6)
data_2014$Date.Time <- as.POSIXct(data_2014$Date.Time, format = "%m/%d/%Y %H:%M:%S")
data_2014$Time <- format(as.POSIXct(data_2014$Date.Time, format = "%m/%d/%Y %H:%M:%S"), format="%H:%M:%S")
data_2014$Date.Time <- ymd_hms(data_2014$Date.Time)
data_2014$day <- factor(day(data_2014$Date.Time))
data_2014$month <- factor(month(data_2014$Date.Time, label = TRUE))
data_2014$year <- factor(year(data_2014$Date.Time))
data_2014$dayofweek <- factor(wday(data_2014$Date.Time, label = TRUE))
data_2014$hour <- factor(hour(hms(data_2014$Time)))
data_2014$minute <- factor(minute(hms(data_2014$Time)))
data_2014$second <- factor(second(hms(data_2014$Time)))
hour <- data_2014 %>%
group_by(hour) %>%
dplyr::summarize(total = n())
ggplot(hour, aes(x=hour, y=total, fill = total))+
geom_bar(stat = "identity")+
scale_fill_distiller(palette = "Spectral")+
theme_dark()

dayofweek <- data_2014 %>%
group_by(dayofweek) %>%
dplyr::summarize(total = n())
ggplot(dayofweek, aes(x=dayofweek, y=total, fill = total))+
geom_bar(stat = "identity")+
scale_fill_distiller(palette = "Spectral")+
theme_dark()

day <- data_2014 %>%
group_by(day) %>%
dplyr::summarize(total = n())
ggplot(day, aes(x=day, y=total, fill = total))+
geom_bar(stat = "identity")+
scale_fill_distiller(palette = "Spectral")+
theme_dark()

month <- data_2014 %>%
group_by(month) %>%
dplyr::summarize(total = n())
ggplot(month, aes(x=month, y=total, fill = total))+
geom_bar(stat = "identity")+
scale_fill_distiller(palette = "Spectral")+
theme_dark()

hourheat <- data_2014 %>%
group_by(minute, hour)%>%
dplyr::summarize(total = n())
## `summarise()` has grouped output by 'minute'. You can override using the `.groups` argument.
ggplot(hourheat, aes(x=hour, y=minute, fill = total))+
geom_tile()+
scale_fill_distiller(palette = "Spectral")

dayofweekheat <- data_2014 %>%
group_by(hour, dayofweek)%>%
dplyr::summarize(total = n())
## `summarise()` has grouped output by 'hour'. You can override using the `.groups` argument.
ggplot(dayofweekheat, aes(x=hour, y=dayofweek, fill = total))+
geom_tile()+
scale_fill_distiller(palette = "Spectral")

dayheat <- data_2014 %>%
group_by(day, hour)%>%
dplyr::summarize(total = n())
## `summarise()` has grouped output by 'day'. You can override using the `.groups` argument.
ggplot(dayheat, aes(x=hour, y=day, fill = total))+
geom_tile()+
scale_fill_distiller(palette = "Spectral")

monthheat <- data_2014 %>%
group_by(hour, month)%>%
dplyr::summarize(total = n())
## `summarise()` has grouped output by 'hour'. You can override using the `.groups` argument.
ggplot(monthheat, aes(x=hour, y=month, fill = total))+
geom_tile()+
scale_fill_distiller(palette = "Spectral")
