Setup
library(ggplot2)
library(tidyverse)
library(gghighlight)
library(plotly)
library(webshot)
screentime <- read.csv("Data/ScreenUse.csv") %>%
arrange(Day)
screentime2 <- read.csv("Data/ScreenUse2.csv")%>%
arrange(Day)
1. My Phone Use
d <- highlight_key(screentime, ~App )
p <- ggplot( d, aes(x = Day, y = Notifications, group = App)) +
theme_bw() +
geom_line() +
ggtitle("Notifications by App per Day")+
theme(plot.title = element_text(hjust = 0.5),
plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "inches"))+
scale_x_discrete(labels=c("1"="Sunday", "2"="Monday", "3"="Tuesday", "4"="Wednesday", "5"="Thursday", "6"="Friday", '7'="Saturday"))
#now ggplotly the newly created ggplot, and add text for the tooltips as needed
gg <- ggplotly( p, tooltip = c("App", "Notifications"))
#set the highlight-options
highlight( gg, on = "plotly_hover", off = "plotly_deselect", color = "red" )
2. My Guess at My Classmate’s Phone Use
d <- highlight_key(screentime2, ~App )
p <- ggplot( d, aes(x = Day, y = Notifications, group = App)) +
theme_bw() +
geom_line() +
ggtitle("Notifications by App per Day")+
theme(plot.title = element_text(hjust = 0.5),
plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "inches"))+
scale_x_discrete(labels=c("1"="Sunday", "2"="Monday", "3"="Tuesday", "4"="Wednesday", "5"="Thursday", "6"="Friday", '7'="Saturday"))
#now ggplotly the newly created ggplot, and add text for the tooltips as needed
gg <- ggplotly( p, tooltip = c("App", "Notifications"))
#set the highlight-options
highlight( gg, on = "plotly_hover", off = "plotly_deselect", color = "red" )