---
title: "Impact of Social Media Usage on Productivity"
Author: "Mohnish Singh"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(ggthemes)
library(quantmod)
library(ggalt)
library(dygraphs)
library(metricsgraphics)
library(xts)
library(plyr)
library(tidyverse)
```
```{r}
DataViz <- read.csv("C:/Users/mks/Google Drive/HU/ANLY512-50/FinalProject/DataVizProject.csv")
DataVizWeekday <- DataViz[ which(DataViz$Weekend == 'N'), ]
DataVizWeekend <- DataViz[ which(DataViz$Weekend == 'Y'), ]
DataVizWeekday_Fbselect_high <- DataVizWeekday[DataVizWeekday$FacebookOffice > 30 & DataVizWeekday$TimeSpentInOffice > 600, ]
DataVizWeekday_Fbselect_low <- DataVizWeekday[DataVizWeekday$FacebookOffice < 10 & DataVizWeekday$TimeSpentInOffice < 540, ]
DataVizWeekday_instselect_high <- DataVizWeekday[DataVizWeekday$InstagramOffice> 8 & DataVizWeekday$TimeSpentInOffice > 600, ]
DataVizWeekday_instselect_low <- DataVizWeekday[DataVizWeekday$InstagramOffice == 0 & DataVizWeekday$TimeSpentInOffice < 720, ]
DataVizWeekday_wappselect_high <- DataVizWeekday[DataVizWeekday$WhatsappOffice > 20 & DataVizWeekday$TimeSpentInOffice > 600, ]
DataVizWeekday_wappselect_low <- DataVizWeekday[DataVizWeekday$WhatsappOffice == 0 & DataVizWeekday$TimeSpentInOffice < 720, ]
DataVizWeekday_totselect_high <- DataVizWeekday[DataVizWeekday$TotalSocialMediaUsage > 50,]
```
Social Media Usage (At Work) {data-orientation=rows}
==========================================================================
Row {.tabset .tabset-fade}
-----------------------------------------------------------------------
### Facebook Usage
```{r}
plotfb <- ggplot(DataVizWeekday, aes(x=FacebookOffice, y=TimeSpentInOffice)) + geom_point(aes(col=FacebookUsageStarted, size=TotalSocialMediaUsageWork)) + geom_smooth(method="loess", se=F) + geom_encircle(aes(x=FacebookOffice, y=TimeSpentInOffice), data=DataVizWeekday_Fbselect_high, color="red", size=2, expand=0.08) + geom_encircle(aes(x=FacebookOffice, y=TimeSpentInOffice), data=DataVizWeekday_Fbselect_low, color="Green", size=2, expand=0.08)+ labs(subtitle="Facebook Usage vs Time spent in Office", y= "Total duration of stay in office (minutes)", x="Total time spent on Facebook in office(minutes)", title = "Scatterplot + Encircle")
plotfb
plotboxfb <-ggplot(DataVizWeekday,aes(FacebookUsageStarted,FacebookOffice,color=City)) + geom_boxplot() + xlab("Timeframe during which Facebook usage started") + ylab("Facebook Usage in Office(Minutes)") + coord_flip() + theme_economist()
plotboxfb
```
### Instagram Usage
```{r}
plotinst <- ggplot(DataVizWeekday, aes(x=InstagramOffice, y=TimeSpentInOffice)) + geom_point(aes(col=InstagramUsageStarted, size=TotalSocialMediaUsageWork)) + geom_smooth(method="loess", se=F) + geom_encircle(aes(x=InstagramOffice, y=TimeSpentInOffice), data=DataVizWeekday_instselect_high, color="red", size=2, expand=0.08) + geom_encircle(aes(x=InstagramOffice, y=TimeSpentInOffice), data=DataVizWeekday_instselect_low, color="Green", size=2, expand=0.08)+ labs(subtitle="Instagram Usage vs Time spent in Office", y= "Total duration of stay in office (minutes)", x="Total time spent on Instagram in office(minutes)", title = "Scatterplot + Encircle")
plotinst
plotboxinst <-ggplot(DataVizWeekday,aes(InstagramUsageStarted,InstagramOffice,color=City)) + geom_boxplot() + xlab("Timeframe during which Instagram usage started") + ylab("Instagram Usage in Office(Minutes)") + coord_flip() + theme_economist()
plotboxinst
```
### WhatsApp Usage
```{r}
plotwapp <- ggplot(DataVizWeekday, aes(x=WhatsappOffice, y=TimeSpentInOffice)) + geom_point(aes(col=WhatsappUsageStarted, size=TotalSocialMediaUsageWork)) + geom_smooth(method="loess", se=F) + geom_encircle(aes(x=WhatsappOffice, y=TimeSpentInOffice), data=DataVizWeekday_wappselect_high, color="red", size=2, expand=0.08) + geom_encircle(aes(x=WhatsappOffice, y=TimeSpentInOffice), data=DataVizWeekday_wappselect_low, color="Green", size=2, expand=0.08)+ labs(subtitle="Whatsapp Usage vs Time spent in Office", y= "Total duration of stay in office (minutes)", x="Total time spent on Whatsapp in office(minutes)", title = "Scatterplot + Encircle")
plotwapp
plotboxwapp <-ggplot(DataVizWeekday,aes(WhatsappUsageStarted,WhatsappOffice,color=City)) + geom_boxplot() + xlab("Timeframe during which Whatsapp usage started") + ylab("Whatsapp Usage in Office(Minutes)") + coord_flip() + theme_economist()
plotboxwapp
```
### Total Social Media Usage
```{r}
plottot <- ggplot(DataVizWeekday, aes(x=TotalSocialMediaUsageWork, y=OfficeOutTime)) + geom_point(aes(col=City, size=TotalSocialMediaUsageWork)) + geom_smooth(method="loess", se=F) + labs(subtitle="Social Media Usage vs Time of leaving Office", y= "Office Out Time", x="Total time spent on Social Media in office (minutes)", title = "Scatterplot + Encircle")
plottot
plottotwk <- ggplot(DataVizWeekday, aes(x=TotalSocialMediaUsageWork, y=WorkOutDuration)) + geom_point(aes(col=Month, size=TotalSocialMediaUsageWork)) + geom_smooth(method="loess", se=F) + labs(subtitle="Social Media Usage vs Time Availability for Workouts", y= "Workout Duration", x="Total time spent on Social Media in office (minutes)", title = "Scatterplot + Encircle")
plottotwk
```
Social Media Usage (Overall) {data-orientation=columns}
==========================================================================
Column
------------------------------------------------------------------------------
### Facebook Usage Trend - Morning vs Rest of the day
```{r}
plothistfb <- ggplot(DataVizWeekday, aes(FacebookTotal, fill=FacebookUsageStarted)) + geom_histogram(binwidth=5) + labs(title="Analysis of Facebook based on usage start time", y= "Count", x="Total time spent on Facebook in minutes (Work+Home)")
plothistfb
```
Column
-------------------------------------
### Instagram Usage Trend - Morning vs Rest of the day
```{r}
plothistinst <- ggplot(DataVizWeekday, aes(InstagramTotal, fill=InstagramUsageStarted)) + geom_histogram(binwidth =2) + labs(title="Analysis of Instagram usage based on usage start time", y= "Count", x="Total time spent on Instagram in minutes (Work+Home)")
plothistinst
```
### Whatsapp Usage Trend - Morning vs Rest of the day
```{r}
plothistwapp <- ggplot(DataVizWeekday, aes(WhatsappTotal, fill=WhatsappUsageStarted)) + geom_histogram(binwidth = 2) + labs(title="Analysis of Whatsapp usage based on usage start time", y= "Count", x="Total time spent on Whatsapp in minutes (Work+Home)")
plothistwapp
```
Social Media Usage (At Work)
Row
Facebook Usage
Instagram Usage
WhatsApp Usage
Total Social Media Usage