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.
As we see in this chart, the total miles travelled on a weekday range from 60 to 80 while those on the weekend range from 20 to 35. This means that the person drives to work every weekday and has a standard weekend routines. Also on the weekend of May 26, July 4 and Sept 1, the drive distance is zero which means that the person did not drive the car was out of town, considering all these were holiday weekends.
In this graph we see that the occupancy of the car spiked during the weekend. The occupancy is 1 or 2 during a weekday and 5 to 7 during the weekend. This means that the person drives alone to work or carpools with another friend while during the weekend, the person goes out with a set of friends or family - indicating that it could be a recreational trip/visit to grocery nearby. We also see that the AC fan speed varies directly with the number of occupants. Hence more the occupants, higher the power of AC needed to cool the car.
We see that the mileage of the car has a direct relationship with the distance, occupants, and AC fan speed which spike during the week and goes during the weekend. THis could be because of mileage reducing as the number of occupants increase. Mileage also reduces with the increase in fan speed. Lastly, mileage could be dependent on the distance - since longer the distance, more consistent the speed and lesser the need for constant acceleration and deceleartion. THis could also be attribued to constant speed on the highway for work.
We see two separate chunks of fan speeds for short and long distances. Through the bubble chart, which also serves as a heat map, we see that the AC fan speed is lower for longer distances while they are higher for shorter distances. Also, the range of temperatures is more contained for long drives than those for short drives. This can be attributed to occupancy, but also to the fact that short distances could be more fragmented and hence demand turning the AC fan to max everytime a person gets in the car during these short trips.
### AC, occupancy, and temperatureHere, we try to see if the car temperature has any relation with the seasonality. By looking at the wekk over week data, we can assume that the person has a similar behaviour during every day of the week. Hence we take every Saturday as a reference and see if the AC temperature shows a trend. As seen from the graph and the trendline, the AC temperature dips during the peak of summer and rises gradually as we approach fall and winter. This shows that the driver compensates for the excessive heat outside by lowering the AC temperature in the car.
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.
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)