library(readr)
library(rmarkdown)
## Warning: package 'rmarkdown' was built under R version 4.3.2
library(ggplot2)
library(dplyr)
## 
## 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(readr)
library(writexl)
## Warning: package 'writexl' was built under R version 4.3.2
library(data.table) 
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
jan <- read_csv("202101-divvy-tripdata.csv")
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 96834 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
feb <- read_csv("202102-divvy-tripdata.csv")  
## Rows: 49622 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
mar<- read_csv("202103-divvy-tripdata.csv")  
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 228496 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
apr <- read_csv("202104-divvy-tripdata.csv")  
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 337230 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
may <- read_csv("202105-divvy-tripdata.csv")
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 531633 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
jun <- read_csv("202106-divvy-tripdata.csv")  
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 729595 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
jul <- read_csv("202107-divvy-tripdata.csv")
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 822410 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
aug <- read_csv("202108-divvy-tripdata.csv")  
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 804352 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
sep <- read_csv("202109-divvy-tripdata.csv")
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 756147 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
oct <- read_csv("202110-divvy-tripdata.csv")  
## Rows: 631226 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
nov <- read_csv("202111-divvy-tripdata.csv")  
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 359978 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
dec <- read_csv("202112-divvy-tripdata.csv")  
## Rows: 247540 Columns: 12
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (11): ride_id, rideable_type, started_at, ended_at, week_days, month, s...
## time  (1): trip_duration
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
colnames(jan)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(feb)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(mar)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(apr)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(may)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(jun)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(jul)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(aug)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(sep)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(oct)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(nov)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
colnames(dec)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "trip_duration"      "week_days"         
##  [7] "month"              "start_station_name" "start_station_id"  
## [10] "end_station_name"   "end_station_id"     "member_casual"
q1 <- rbind (jan, feb, mar)
q2 <- rbind (apr, may, jun)
q3 <- rbind (jul, aug, sep)
q4 <- rbind (oct, nov, dec)
full_data <- rbind(jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec)
remove(jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec)
str(q1)
## spc_tbl_ [374,952 × 12] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ ride_id           : chr [1:374952] "E19E6F1B8D4C42ED" "DC88F20C2C55F27F" "EC45C94683FE3F27" "4FA453A75AE377DB" ...
##  $ rideable_type     : chr [1:374952] "electric_bike" "electric_bike" "electric_bike" "electric_bike" ...
##  $ started_at        : chr [1:374952] "23-01-2021 16:14" "27-01-2021 18:43" "21-01-2021 22:35" "07-01-2021 13:31" ...
##  $ ended_at          : chr [1:374952] "23-01-2021 16:24" "27-01-2021 18:47" "21-01-2021 22:37" "07-01-2021 13:42" ...
##  $ trip_duration     : 'hms' num [1:374952] 00:10:25 00:04:04 00:01:20 00:11:42 ...
##   ..- attr(*, "units")= chr "secs"
##  $ week_days         : chr [1:374952] "Saturday" "Wednesday" "Thursday" "Thursday" ...
##  $ month             : chr [1:374952] "January" "January" "January" "January" ...
##  $ start_station_name: chr [1:374952] "California Ave & Cortez St" "California Ave & Cortez St" "California Ave & Cortez St" "California Ave & Cortez St" ...
##  $ start_station_id  : chr [1:374952] "17660" "17660" "17660" "17660" ...
##  $ end_station_name  : chr [1:374952] NA NA NA NA ...
##  $ end_station_id    : chr [1:374952] NA NA NA NA ...
##  $ member_casual     : chr [1:374952] "member" "member" "member" "member" ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   ride_id = col_character(),
##   ..   rideable_type = col_character(),
##   ..   started_at = col_character(),
##   ..   ended_at = col_character(),
##   ..   trip_duration = col_time(format = ""),
##   ..   week_days = col_character(),
##   ..   month = col_character(),
##   ..   start_station_name = col_character(),
##   ..   start_station_id = col_character(),
##   ..   end_station_name = col_character(),
##   ..   end_station_id = col_character(),
##   ..   member_casual = col_character()
##   .. )
##  - attr(*, "problems")=<externalptr>
str(q2)
## spc_tbl_ [1,598,458 × 12] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ ride_id           : chr [1:1598458] "6C992BD37A98A63F" "1E0145613A209000" "E498E15508A80BAD" "1887262AD101C604" ...
##  $ rideable_type     : chr [1:1598458] "classic_bike" "docked_bike" "docked_bike" "classic_bike" ...
##  $ started_at        : chr [1:1598458] "12-04-2021 18:25" "27-04-2021 17:27" "03-04-2021 12:42" "17-04-2021 09:17" ...
##  $ ended_at          : chr [1:1598458] "12-04-2021 18:56" "27-04-2021 18:31" "07-04-2021 11:40" "17-04-2021 09:42" ...
##  $ trip_duration     : 'hms' num [1:1598458] 00:31:19 01:04:18 22:57:39 00:25:06 ...
##   ..- attr(*, "units")= chr "secs"
##  $ week_days         : chr [1:1598458] "Monday" "Tuesday" "Saturday" "Saturday" ...
##  $ month             : chr [1:1598458] "April" "April" "April" "April" ...
##  $ start_station_name: chr [1:1598458] "State St & Pearson St" "Dorchester Ave & 49th St" "Loomis Blvd & 84th St" "Honore St & Division St" ...
##  $ start_station_id  : chr [1:1598458] "TA1307000061" "KA1503000069" "20121" "TA1305000034" ...
##  $ end_station_name  : chr [1:1598458] "Southport Ave & Waveland Ave" "Dorchester Ave & 49th St" "Loomis Blvd & 84th St" "Southport Ave & Waveland Ave" ...
##  $ end_station_id    : chr [1:1598458] "13235" "KA1503000069" "20121" "13235" ...
##  $ member_casual     : chr [1:1598458] "member" "casual" "casual" "member" ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   ride_id = col_character(),
##   ..   rideable_type = col_character(),
##   ..   started_at = col_character(),
##   ..   ended_at = col_character(),
##   ..   trip_duration = col_time(format = ""),
##   ..   week_days = col_character(),
##   ..   month = col_character(),
##   ..   start_station_name = col_character(),
##   ..   start_station_id = col_character(),
##   ..   end_station_name = col_character(),
##   ..   end_station_id = col_character(),
##   ..   member_casual = col_character()
##   .. )
##  - attr(*, "problems")=<externalptr>
str(q3)
## spc_tbl_ [2,382,909 × 12] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ ride_id           : chr [1:2382909] "0A1B623926EF4E16" "B2D5583A5A5E76EE" "6F264597DDBF427A" "379B58EAB20E8AA5" ...
##  $ rideable_type     : chr [1:2382909] "docked_bike" "classic_bike" "classic_bike" "classic_bike" ...
##  $ started_at        : chr [1:2382909] "02-07-2021 14:44" "07-07-2021 16:57" "25-07-2021 11:30" "08-07-2021 22:08" ...
##  $ ended_at          : chr [1:2382909] "02-07-2021 15:19" "07-07-2021 17:16" "25-07-2021 11:48" "08-07-2021 22:23" ...
##  $ trip_duration     : 'hms' num [1:2382909] 00:35:22 00:18:27 00:17:50 00:15:02 ...
##   ..- attr(*, "units")= chr "secs"
##  $ week_days         : chr [1:2382909] "Friday" "Wednesday" "Sunday" "Thursday" ...
##  $ month             : chr [1:2382909] "July" "July" "July" "July" ...
##  $ start_station_name: chr [1:2382909] "Michigan Ave & Washington St" "California Ave & Cortez St" "Wabash Ave & 16th St" "California Ave & Cortez St" ...
##  $ start_station_id  : chr [1:2382909] "13001" "17660" "SL-012" "17660" ...
##  $ end_station_name  : chr [1:2382909] "Halsted St & North Branch St" "Wood St & Hubbard St" "Rush St & Hubbard St" "Carpenter St & Huron St" ...
##  $ end_station_id    : chr [1:2382909] "KA1504000117" "13432" "KA1503000044" "13196" ...
##  $ member_casual     : chr [1:2382909] "casual" "casual" "member" "member" ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   ride_id = col_character(),
##   ..   rideable_type = col_character(),
##   ..   started_at = col_character(),
##   ..   ended_at = col_character(),
##   ..   trip_duration = col_time(format = ""),
##   ..   week_days = col_character(),
##   ..   month = col_character(),
##   ..   start_station_name = col_character(),
##   ..   start_station_id = col_character(),
##   ..   end_station_name = col_character(),
##   ..   end_station_id = col_character(),
##   ..   member_casual = col_character()
##   .. )
##  - attr(*, "problems")=<externalptr>
str(q4)
## spc_tbl_ [1,238,744 × 12] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ ride_id           : chr [1:1238744] "620BC6107255BF4C" "4471C70731AB2E45" "26CA69D43D15EE14" "362947F0437E1514" ...
##  $ rideable_type     : chr [1:1238744] "electric_bike" "electric_bike" "electric_bike" "electric_bike" ...
##  $ started_at        : chr [1:1238744] "22-10-2021 12:46" "21-10-2021 09:12" "16-10-2021 16:28" "16-10-2021 16:17" ...
##  $ ended_at          : chr [1:1238744] "22-10-2021 12:49" "21-10-2021 09:14" "16-10-2021 16:36" "16-10-2021 16:19" ...
##  $ trip_duration     : 'hms' num [1:1238744] 00:03:08 00:01:37 00:07:47 00:01:15 ...
##   ..- attr(*, "units")= chr "secs"
##  $ week_days         : chr [1:1238744] "Friday" "Thursday" "Saturday" "Saturday" ...
##  $ month             : chr [1:1238744] "October" "October" "October" "October" ...
##  $ start_station_name: chr [1:1238744] "Kingsbury St & Kinzie St" NA NA NA ...
##  $ start_station_id  : chr [1:1238744] "KA1503000043" NA NA NA ...
##  $ end_station_name  : chr [1:1238744] NA NA NA NA ...
##  $ end_station_id    : chr [1:1238744] NA NA NA NA ...
##  $ member_casual     : chr [1:1238744] "member" "member" "member" "member" ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   ride_id = col_character(),
##   ..   rideable_type = col_character(),
##   ..   started_at = col_character(),
##   ..   ended_at = col_character(),
##   ..   trip_duration = col_time(format = ""),
##   ..   week_days = col_character(),
##   ..   month = col_character(),
##   ..   start_station_name = col_character(),
##   ..   start_station_id = col_character(),
##   ..   end_station_name = col_character(),
##   ..   end_station_id = col_character(),
##   ..   member_casual = col_character()
##   .. )
##  - attr(*, "problems")=<externalptr>
str(full_data)
## spc_tbl_ [5,595,063 × 12] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ ride_id           : chr [1:5595063] "E19E6F1B8D4C42ED" "DC88F20C2C55F27F" "EC45C94683FE3F27" "4FA453A75AE377DB" ...
##  $ rideable_type     : chr [1:5595063] "electric_bike" "electric_bike" "electric_bike" "electric_bike" ...
##  $ started_at        : chr [1:5595063] "23-01-2021 16:14" "27-01-2021 18:43" "21-01-2021 22:35" "07-01-2021 13:31" ...
##  $ ended_at          : chr [1:5595063] "23-01-2021 16:24" "27-01-2021 18:47" "21-01-2021 22:37" "07-01-2021 13:42" ...
##  $ trip_duration     : 'hms' num [1:5595063] 00:10:25 00:04:04 00:01:20 00:11:42 ...
##   ..- attr(*, "units")= chr "secs"
##  $ week_days         : chr [1:5595063] "Saturday" "Wednesday" "Thursday" "Thursday" ...
##  $ month             : chr [1:5595063] "January" "January" "January" "January" ...
##  $ start_station_name: chr [1:5595063] "California Ave & Cortez St" "California Ave & Cortez St" "California Ave & Cortez St" "California Ave & Cortez St" ...
##  $ start_station_id  : chr [1:5595063] "17660" "17660" "17660" "17660" ...
##  $ end_station_name  : chr [1:5595063] NA NA NA NA ...
##  $ end_station_id    : chr [1:5595063] NA NA NA NA ...
##  $ member_casual     : chr [1:5595063] "member" "member" "member" "member" ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   ride_id = col_character(),
##   ..   rideable_type = col_character(),
##   ..   started_at = col_character(),
##   ..   ended_at = col_character(),
##   ..   trip_duration = col_time(format = ""),
##   ..   week_days = col_character(),
##   ..   month = col_character(),
##   ..   start_station_name = col_character(),
##   ..   start_station_id = col_character(),
##   ..   end_station_name = col_character(),
##   ..   end_station_id = col_character(),
##   ..   member_casual = col_character()
##   .. )
##  - attr(*, "problems")=<externalptr>
q1 <- na.omit(q1)
q2 <- na.omit(q2)
q3 <- na.omit(q3)
q4 <- na.omit(q4)
full_data <- na.omit(full_data)
q1 <- mutate(q1, trip_duration=as.numeric(trip_duration))
q2 <- mutate(q2, trip_duration=as.numeric(trip_duration))
q3 <- mutate(q3, trip_duration=as.numeric(trip_duration))
q4 <- mutate(q4, trip_duration=as.numeric(trip_duration))
full_data <- mutate(full_data, trip_duration2=as.numeric(trip_duration))
full_data <- rbind(q1, q2, q3, q4)
remove(q1, q2, q3, q4)
full_data %>% 
  group_by(member_casual) %>% 
  summarise(number_of_rides = n()) %>%
  arrange(member_casual)  %>% 
  ggplot(aes(x = member_casual, 
             y = number_of_rides, 
             fill = member_casual)) + 
  labs(fill='Rider Group') +
  geom_col(position = "dodge") +
  ggtitle(label = 'Total Rides per Year', subtitle = 'Casual Riders vs Members') + 
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(plot.subtitle = element_text(hjust = 0.5)) +
  xlab('Rider Group') + ylab('Number of Rides') +
  geom_text(aes(label = number_of_rides), vjust = 0)

full_data$month <- ordered(full_data$month, levels=c("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")) #rearrange months to January -> December 
full_data %>% 
  group_by(member_casual, month) %>% 
  summarise(number_of_rides = n()) %>% 
  arrange(member_casual, month)  %>% 
  ggplot(aes(x = month, 
             y = number_of_rides, 
             fill = member_casual)) + 
  labs(fill='Rider Group') +
  geom_col(position = "dodge") +
  ggtitle(label = 'Total Rides per Month', subtitle = 'Casual Riders vs Members') + 
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(plot.subtitle = element_text(hjust = 0.5)) +
  xlab('Month') + ylab('Number of Rides') +
  geom_text(aes(label = number_of_rides, hjust = "left"), position = position_dodge(width = 0.9),size = 3, angle = 90)
## `summarise()` has grouped output by 'member_casual'. You can override using the
## `.groups` argument.

full_data$week_days <- ordered(full_data$week_days, levels=c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")) #rearrange weekdays to monday -> sunday 
full_data %>% 
  group_by(member_casual, week_days) %>% 
  summarise(number_of_rides = n()) %>%
  arrange(member_casual, week_days)  %>% 
  ggplot(aes(x = week_days, 
             y = number_of_rides, 
             fill = member_casual)) +
  labs(fill='Rider Group') +
  geom_col(position = "dodge") +
  ggtitle(label = 'Total Rides per Day', subtitle = 'Casual Riders vs Members') + 
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(plot.subtitle = element_text(hjust = 0.5)) +
  xlab('Day of Week') + ylab('Number of Rides') +
  geom_text(aes(label = number_of_rides, hjust = "right"), position = position_dodge(width = 0.9),size = 3, angle = 90)
## `summarise()` has grouped output by 'member_casual'. You can override using the
## `.groups` argument.

full_data %>% 
  group_by(member_casual) %>% 
  summarise(average_duration = mean(trip_duration)) %>% 
  arrange(member_casual)  %>% 
  ggplot(aes(x = member_casual, 
             y = average_duration/60, 
             fill = member_casual)) +
  labs(fill='Rider Group') +
  geom_col(position = "dodge") +
  ggtitle(label = 'Average Trip Duration', subtitle = 'Casual Riders vs Members') + 
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(plot.subtitle = element_text(hjust = 0.5)) +
  xlab('Rider Group') + ylab('Trip Duration in Minutes') +
  geom_text(aes(label = round(average_duration/60, digits = 2)), vjust = 0)

full_data %>% 
  group_by(member_casual, month) %>% 
  summarise(average_duration = mean(trip_duration)) %>% 
  arrange(member_casual, month)  %>% 
  ggplot(aes(x = month, 
             y = average_duration/60, 
             fill = member_casual)) +
  labs(fill='Raider Group') +
  geom_col(position = "dodge") +
  ggtitle(label = 'Average Trip Duration by Month', subtitle = 'Casual Riders vs Members') + 
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(plot.subtitle = element_text(hjust = 0.5)) +
  xlab('Month') + ylab('Trip Duration in Minutes') +
  geom_text(aes(label = round(average_duration/60, digits = 2), hjust = "right"), position = position_dodge(width = 0.9),size = 3, angle = 90)
## `summarise()` has grouped output by 'member_casual'. You can override using the
## `.groups` argument.

full_data %>% 
  group_by(member_casual, week_days) %>% 
  summarise(average_duration = mean(trip_duration)) %>% 
  arrange(member_casual, week_days)  %>% 
  ggplot(aes(x = week_days, 
             y = average_duration/60, 
             fill = member_casual)) +
  labs(fill='Rider Group') +
  geom_col(position = "dodge") +
  ggtitle(label = 'Average Trip Duration by Weekday', subtitle = 'Casual Riders vs Members') + 
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(plot.subtitle = element_text(hjust = 0.5)) +
  xlab('Day of Week') + ylab('Trip Duration in Minutes') +
  geom_text(aes(label = round(average_duration/60, digits = 2), hjust = "right"), position = position_dodge(width = 0.9),size = 3, angle = 90)
## `summarise()` has grouped output by 'member_casual'. You can override using the
## `.groups` argument.

full_data %>% 
  group_by(member_casual, rideable_type) %>% 
  summarise(number_of_rides = n()) %>%
  arrange(member_casual, rideable_type)  %>% 
  ggplot(aes(x = rideable_type, 
             y = number_of_rides, 
             fill = member_casual)) + 
  labs(fill='Rider Group') +
  geom_col(position = "dodge") +
  ggtitle(label = 'Total Rides per Year by Bike Type', subtitle = 'Casual Riders vs Members') +  
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(plot.subtitle = element_text(hjust = 0.5)) +
  xlab('Bike Type') + ylab('Number of Rides') +
  geom_text(aes(label = number_of_rides), position = position_dodge(width = 0.9), vjust = 0)
## `summarise()` has grouped output by 'member_casual'. You can override using the
## `.groups` argument.

full_data %>% 
  group_by(member_casual, rideable_type) %>% 
  summarise(average_duration = mean(trip_duration)) %>% 
  arrange(member_casual, rideable_type)  %>% 
  ggplot(aes(x = rideable_type, 
             y = average_duration/60, 
             fill = member_casual)) +
  labs(fill='Rider Group') +
  geom_col(position = "dodge") +
  ggtitle(label = 'Average Trip Duration by Bike Type', subtitle = 'Casual Riders vs Members') + 
  theme(plot.title = element_text(hjust = 0.5)) +
  theme(plot.subtitle = element_text(hjust = 0.5)) +
  xlab('Bike Type') + ylab('Trip Duration in Minutes') +
  geom_text(aes(label = round(average_duration/60, digits = 2)), position = position_dodge(width = 0.9), vjust = 0)
## `summarise()` has grouped output by 'member_casual'. You can override using the
## `.groups` argument.