Take Home Exercise 4 is to reveal the daily routines of two
selected participant of the city of Engagement, Ohio USA.
ViSIElse,
a graphical tool to visualize behavioural observations, and other
appropriate visual analytics methods will be used.
packages = c('scales', 'viridis',
'lubridate', 'ggthemes',
'gridExtra', 'tidyverse',
'readxl', 'knitr',
'data.table', 'ViSiElse')
for (p in packages){
if(!require(p, character.only = T)){
install.packages(p)
}
library(p, character.only = T)
}
logs_recreation <- read_csv(“data/logs1_10.csv”) %>% select(timestamp, participantId, currentMode) %>% filter(currentMode == “AtRecreation”) %>% mutate(wkdays = weekdays(ymd_hms(timestamp, quiet = TRUE))) %>% mutate(hour = hour(ymd_hms(timestamp, quiet = TRUE))) %>% count(wkdays, hour) %>% ungroup() %>% na.omit()
write_csv(logs_recreation,‘data/logs_recreation.csv’ )
logs_recreation <- read_csv("data/logs_recreation.csv")
ggplot(logs_recreation, aes(hour, wkdays, fill = n))+
geom_tile(color = "white", size = 0.1)+
theme_tufte(base_family = "Helvetica")+
coord_equal()+
scale_fill_gradient(name = "# of Recreation",
low = "sky blue",
high = "dark blue")+
labs(x = NULL, Y= NULL,
title = "Recreation by Weekday and Time of the Day")+
theme(axis.ticks = element_blank(),
plot.title = element_text(hjust = 0.5),
legend.title = element_text(size = 8),
legend.text = element_text(size = 6) )
logs_sleep <- read_csv(“data/logs1_10.csv”) %>% select(timestamp, participantId, sleepStatus) %>% filter (participantId == 0) %>% mutate(date = as.IDate(ymd_hms(timestamp, quiet = TRUE))) %>% mutate(minutes = hour(ymd_hms(timestamp))*60+minute(ymd_hms(timestamp))) %>% group_by(date, sleepStatus) %>% summarise(time = min(minutes)) %>% pivot_wider(names_from = sleepStatus, values_from = time)
logs_mode <- read_csv(“data/logs1_10.csv”) %>% select(timestamp, participantId, currentMode) %>% filter (participantId == 0) %>% mutate(date = as.IDate(ymd_hms(timestamp, quiet = TRUE))) %>% mutate(minutes = hour(ymd_hms(timestamp))*60+minute(ymd_hms(timestamp))) %>% group_by(date, currentMode) %>% summarise(time = min(minutes)) %>% pivot_wider(names_from = currentMode, values_from = time)
logs_hungry <- read_csv(“data/logs1_10.csv”) %>% select(timestamp, participantId, hungerStatus) %>% filter (participantId == 0) %>% mutate(date = as.IDate(ymd_hms(timestamp, quiet = TRUE))) %>% mutate(minutes = hour(ymd_hms(timestamp))*60+minute(ymd_hms(timestamp))) %>% group_by(date,hungerStatus) %>% summarise(time = min(minutes)) %>% pivot_wider(names_from = hungerStatus, values_from = time)
daily_life_p <- left_join(logs_sleep, logs_mode) daily_life <- left_join(daily_life_p, logs_hungry) write_csv(daily_life, “data/daily_life.csv”)
daily_life <- read_csv("data/daily_life.csv")
visielse(daily_life)
-parameters
method : global
grwithin :
quantity : N
informer : median
tests : FALSE
threshold.test : 0.01
pixel : 20
t_0 : 0
-MATp : 13 x 67 sparse Matrix of class "dgCMatrix"
-L : 0 x 0 data.frame
-idsort : 0 x 0 matrix
-MATpsup : 0 x 0 sparse Matrix of class "dgCMatrix"
-idsup : length 0 vector
-Lsup : 0 x 0 data.frame
-colvect : 1 x 1 matrix
-BZL : 0 x 0 sparse Matrix of class "dgCMatrix"
-book : 13 x 6 ViSibook
-group : length 0 factor
-vect_tps : length 67 vector
-testsP : length 0 vector
-informers : 3 x 13 matrix
daily_life1 <- read_csv("data/daily_life1.csv")
visielse(daily_life1)
-parameters
method : global
grwithin :
quantity : N
informer : median
tests : FALSE
threshold.test : 0.01
pixel : 20
t_0 : 0
-MATp : 13 x 70 sparse Matrix of class "dgCMatrix"
-L : 0 x 0 data.frame
-idsort : 0 x 0 matrix
-MATpsup : 0 x 0 sparse Matrix of class "dgCMatrix"
-idsup : length 0 vector
-Lsup : 0 x 0 data.frame
-colvect : 1 x 1 matrix
-BZL : 0 x 0 sparse Matrix of class "dgCMatrix"
-book : 13 x 6 ViSibook
-group : length 0 factor
-vect_tps : length 70 vector
-testsP : length 0 vector
-informers : 3 x 13 matrix