Project Overview

Column

In this case study, we are analysing a user behaviour based on his driving patterns. We have a few variables such as distance travelledn, the average speed, average AC temperature, occupancy etc from which we try to deduce the lifestyle of the driver. The goal of this project is to collect, analyze and visualize data using the tools and methods covered in the ANLY512 class. For this exercise, I will be using some of the information available online on driving statistics of a user in the state of North Carolina to understand the behaviour more closely and see if any of his driving habits affectb the car performance/mileage.We have the driving data of the user from May 1 2018 to Nov 1 2018.

Conclusion

Column

In conclusion, we can say that the user has a regular job every weekday for which he travells every week day (no work from home) and the user lives about 35-40 miles away from work (total dist is 65-80). The user has weekend rituals with friends or family as we see through the high occupancy rates during the weekends. Also, the user took vacations during the long weekends which is indicated by the 0 miles during these weekends. We can claim that the weekend trips are shorter fragmented trips since the AC fan and temperature fluctuates a lot. We also see how the car performs based on several factors such as speed, occupancy, AC usage and it indicates that the mileage reduces as the distance reduces and occupancy increases since the car needs more power as people increase, and the fact that the user might be driving at consistent speed (cruise control) when going to work.

Source Code

Column

library(flexdashboard)

library(dplyr)

library(plotly)

library(dygraphs)

library(xts)

library(tidyquant)

library(ggplot2)

dataset2 <- read_xlsx(“C:/Users/HPi/OneDrive - HP Inc/Pradosh/Personal/Harrisburg/Course 512/Carperformance.xlsx”)

PLOT: Distance pattern

plot_ly(dataset2, x = ~Date, y = ~Distance_in_miles) %>% add_lines() %>% layout (title = “Total miles travelled in a day”, xaxis = list(title = “Date”), yaxis = list(title = “Distance travelled in miles”))

PLOT: AC fan speed variation with occupancy

plot_ly(dataset2, x = ~Date, y = ~AC_fan_speed, name = ‘AC Fan speed’, type = ‘scatter’, mode = ‘lines’) %>%

add_trace(y = ~Occupancy , name = ‘Occupancy’, type = ‘bar’)

PLOT: Mileage variation with AC fan speed

plot_ly(dataset2, x = ~Date, y = ~Mileage_mpg, name = ‘Milaege in mpg’, type = ‘scatter’, mode = ‘lines’) %>%

add_trace(y = ~AC_fan_speed , name = ‘AC fan speed’, type = ‘bar’)

PLOT: Mileage variation with Distance

plot_ly(dataset2,x = ~Date, y = ~Distance_in_miles, name = ‘Distance’, type = ‘scatter’, mode = ‘lines’, fill = ‘tozeroy’) %>%

add_trace(x = ~Date, y = ~Mileage_mpg, name = ‘Mileage’, fill = ‘tozeroy’)%>% layout(xaxis = list(title = ‘Distance’), yaxis = list(title = ‘Mileage’))

PLOT: Bubble plot of AC, Occupancy, and temperature

plot_ly(dataset2, x = ~Distance_in_miles, y = ~AC_temperature, type = ‘scatter’, mode = ‘markers’, marker = list(size = ~AC_fan_speed*4, opacity = 0.5)) %>% layout(title = ‘AC fluctuation with distance’)

PLOT: AC Temperature over the summer

DataSaturday <- dataset2[which(dataset2$Day == “Saturday”),]

plot_ly(DataSaturday, x = ~Date, color = I(“black”)) %>% add_markers(y = ~AC_temperature, showlegend = FALSE) %>% add_lines(y = ~fitted(loess(AC_temperature ~ Day_num)), line = list(color = ‘#07A4B5’), name = “Loess Smoother”, showlegend = TRUE)