# packages ----
library(plyr)
library(stringr)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.1     ✔ readr   1.3.1
## ✔ tibble  2.1.3     ✔ purrr   0.3.2
## ✔ tidyr   1.0.0     ✔ dplyr   0.8.3
## ✔ ggplot2 3.2.1     ✔ forcats 0.4.0
## ── Conflicts ────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::arrange()   masks plyr::arrange()
## ✖ purrr::compact()   masks plyr::compact()
## ✖ dplyr::count()     masks plyr::count()
## ✖ dplyr::failwith()  masks plyr::failwith()
## ✖ dplyr::filter()    masks stats::filter()
## ✖ dplyr::id()        masks plyr::id()
## ✖ dplyr::lag()       masks stats::lag()
## ✖ dplyr::mutate()    masks plyr::mutate()
## ✖ dplyr::rename()    masks plyr::rename()
## ✖ dplyr::summarise() masks plyr::summarise()
## ✖ dplyr::summarize() masks plyr::summarize()
library(tidyr)
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:plyr':
## 
##     here
## The following object is masked from 'package:base':
## 
##     date
library(kableExtra)
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
library(dplyr)
library(scales)
## 
## Attaching package: 'scales'
## The following object is masked from 'package:purrr':
## 
##     discard
## The following object is masked from 'package:readr':
## 
##     col_factor
library(ggplot2)

# parameters ----
dPath <- "/Volumes/hum-csafe/Research Projects/FoliakiPhD/tudData/" # edit for your set up
dataF <- path.expand(paste0(dPath, "TUD Weekdays 050520.csv"))

1 Time Use Diary

Importing Weekends dataframe

The dataframe is a wide format. I had to clean the data by correcting typo and translating some of the data into english. So the file is not as original as it is when export from qualtrics.

# read in my dataframe
weekdays <- read.csv(dataF, na.strings=c(""), check.names = FALSE, header = TRUE, as.is=TRUE)

head(weekdays)
##     Village Household ID       Day  3:00 AM  3:30 AM  4:00 AM  4:30 AM
## 1      Fasi           17    Monday Sleeping Sleeping Sleeping Sleeping
## 2      Fasi           17    Monday     <NA>     <NA>     <NA>     <NA>
## 3     Fanga            2    Monday Sleeping Sleeping Sleeping Sleeping
## 4     Fanga            2    Monday     <NA>     <NA>     <NA>     <NA>
## 5 Fangaloto            7 Wednesday Sleeping Sleeping Sleeping Sleeping
## 6 Fangaloto            7 Wednesday     <NA>     <NA>     <NA>     <NA>
##    5:00 AM  5:30 AM  6:00 AM         6:30 AM               7:00 AM
## 1 Sleeping Sleeping  Woke up       Showering             Breakfast
## 2     <NA>     <NA>     <NA> Getting dressed                  <NA>
## 3 Sleeping Sleeping Sleeping        Sleeping               Woke up
## 4     <NA>     <NA>     <NA>            <NA>             Showering
## 5 Sleeping Sleeping Sleeping        Sleeping               Woke up
## 6     <NA>     <NA>     <NA>            <NA> Listen to music/radio
##                 7:30 AM               8:00 AM             8:30 AM 9:00 AM
## 1             Breakfast        Driving (work)                Work    Work
## 2                  <NA>                  <NA>                <NA>    <NA>
## 3       Getting dressed        Walking (work)                Work    Work
## 4             Breakfast                  <NA>                <NA>    <NA>
## 5       Feeding animals       Getting dressed      Driving (work)    Work
## 6 Listen to music/radio Listen to music/radio Driving (drop kids)    <NA>
##   9:30 AM 10:00 AM 10:30 AM 11:00 AM 11:30 AM 12:00 PM 12:30 PM 1:00 PM
## 1    Work     Work     Work     Work     Work     Work     Work    Work
## 2    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 3    Work     Work     Work     Work     Work     Work     Work    Work
## 4    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
## 5    Work     Work     Work     Work     Work     Work     Work    Work
## 6    <NA>     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>    <NA>
##   1:30 PM 2:00 PM 2:30 PM 3:00 PM 3:30 PM 4:00 PM 4:30 PM        5:00 PM
## 1    Work    Work    Work    Work    Work    Work    Work           Home
## 2    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>           <NA>
## 3    Work    Work    Work    Work    Work    Work    Work Walking (home)
## 4    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>           <NA>
## 5    Work    Work    Work    Work    Work    Work    Work           Home
## 6    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>           <NA>
##           5:30 PM 6:00 PM 6:30 PM              7:00 PM
## 1         Cooking  Dinner  Dinner               Dinner
## 2            <NA>    <NA>    <NA>                 <NA>
## 3  Walking (home) Cooking Cooking Watching movies (TV)
## 4            <NA> Tidy up Laundry               Dinner
## 5 Feeding animals Cooking Cooking              Cooking
## 6            <NA>    <NA>    <NA>                 <NA>
##                7:30 PM              8:00 PM               8:30 PM
## 1            Showering            Showering Mobile devices (work)
## 2                 <NA>                 <NA>                  <NA>
## 3 Watching movies (TV) Watching movies (TV)  Watching movies (TV)
## 4                 <NA>                 <NA>                  <NA>
## 5               Dinner      Family devotion  Watching movies (TV)
## 6                 <NA>                 <NA>                  <NA>
##                 9:00 PM               9:30 PM             10:00 PM
## 1 Mobile devices (work) Mobile devices (work)             Sleeping
## 2                  <NA>                  <NA>                 <NA>
## 3  Watching movies (TV)  Watching movies (TV)            Showering
## 4                  <NA>                  <NA>                 <NA>
## 5  Watching movies (TV)  Watching movies (TV) Watching movies (TV)
## 6                  <NA>                  <NA>                 <NA>
##               10:30 PM              11:00 PM              11:30 PM
## 1             Sleeping              Sleeping              Sleeping
## 2                 <NA>                  <NA>                  <NA>
## 3            Showering Mobile devices (work)               Reading
## 4                 <NA> Listen to music/radio Listen to music/radio
## 5 Watching movies (TV)              Sleeping              Sleeping
## 6                 <NA>                  <NA>                  <NA>
##   12:00 AM 12:30 AM  1:00 AM  1:30 AM  2:00 AM  2:30 AM
## 1 Sleeping Sleeping Sleeping Sleeping Sleeping Sleeping
## 2     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 3  Reading  Reading Sleeping Sleeping Sleeping Sleeping
## 4     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>
## 5 Sleeping Sleeping Sleeping Sleeping Sleeping Sleeping
## 6     <NA>     <NA>     <NA>     <NA>     <NA>     <NA>

Converting the wide dataframe to long dataframe for easier analysis

Ive noticed that the time is in a character format rather than date. i need to change it to date

see below

longweekdays <- weekdays %>%
  gather(Time, Activity, 4:51)

head(longweekdays)
##     Village Household ID       Day    Time Activity
## 1      Fasi           17    Monday 3:00 AM Sleeping
## 2      Fasi           17    Monday 3:00 AM     <NA>
## 3     Fanga            2    Monday 3:00 AM Sleeping
## 4     Fanga            2    Monday 3:00 AM     <NA>
## 5 Fangaloto            7 Wednesday 3:00 AM Sleeping
## 6 Fangaloto            7 Wednesday 3:00 AM     <NA>

Sorting the TUD dataframe, Firstly, as you can see previously some respondents do not have a secondary activity (i.e NA). Secondly, the data is sorted by time. I think it would be easier to sorted by Household ID. So here i am sorting the data based on ID number

# sorting my dataframe in accending order based on the Household ID
weekdayOrder <- order(longweekdays$`Household ID`)
head(weekdayOrder)
## [1]   3   4 181 182 359 360
# Applying the sorting order into my "longweekdends" dataframe and call it sortweekends
sortweekdays <- longweekdays[weekdayOrder,]
head(sortweekdays)
##     Village Household ID    Day    Time Activity
## 3     Fanga            2 Monday 3:00 AM Sleeping
## 4     Fanga            2 Monday 3:00 AM     <NA>
## 181   Fanga            2 Monday 3:30 AM Sleeping
## 182   Fanga            2 Monday 3:30 AM     <NA>
## 359   Fanga            2 Monday 4:00 AM Sleeping
## 360   Fanga            2 Monday 4:00 AM     <NA>
names(sortweekdays)
## [1] "Village"      "Household ID" "Day"          "Time"        
## [5] "Activity"

Here i am seprating the activity columm into a primary activity and a secondary activity

The issue im facing with is the date. It in character and alsoit picked up the current date (2020) rather than the date from the TUD.

BA: I can’t see a date variable. How would R know which date the diary was completed on?

Im trying to sort the date but it comes back N/A

see below

# Since both the first and second activiies are in one column, i need to separate them into two columns

#call the number of row in my dataframe for the maximum row for my sequence function
nrow(sortweekdays)
## [1] 8544
#create a new dataframe "newdata" for the primary activity only (all odd rows)
newdata <- sortweekdays[seq(1,8543,2),]
head(newdata)
##     Village Household ID    Day    Time Activity
## 3     Fanga            2 Monday 3:00 AM Sleeping
## 181   Fanga            2 Monday 3:30 AM Sleeping
## 359   Fanga            2 Monday 4:00 AM Sleeping
## 537   Fanga            2 Monday 4:30 AM Sleeping
## 715   Fanga            2 Monday 5:00 AM Sleeping
## 893   Fanga            2 Monday 5:30 AM Sleeping
#create a new datagame "newdata1" for the secondary activity (oall even rows)
newdata1 <- sortweekdays[seq(2,8544,2),]
head(newdata1)
##     Village Household ID    Day    Time Activity
## 4     Fanga            2 Monday 3:00 AM     <NA>
## 182   Fanga            2 Monday 3:30 AM     <NA>
## 360   Fanga            2 Monday 4:00 AM     <NA>
## 538   Fanga            2 Monday 4:30 AM     <NA>
## 716   Fanga            2 Monday 5:00 AM     <NA>
## 894   Fanga            2 Monday 5:30 AM     <NA>
#since i have separated my two acitvities, i need to merge them into one dataframe
newdata$Activity2 <- newdata1$Activity

kableExtra::kable(head(newdata), caption = "Test merged long form data") %>%
  kable_styling()
Table 1.1: Test merged long form data
Village Household ID Day Time Activity Activity2
3 Fanga 2 Monday 3:00 AM Sleeping NA
181 Fanga 2 Monday 3:30 AM Sleeping NA
359 Fanga 2 Monday 4:00 AM Sleeping NA
537 Fanga 2 Monday 4:30 AM Sleeping NA
715 Fanga 2 Monday 5:00 AM Sleeping NA
893 Fanga 2 Monday 5:30 AM Sleeping NA

BA: fix the time variable so it looks like and acts like HH:MM

#newdata$rawTime <- hms::parse_hm(newdata$Time) # this will only be right for AM
#newdata$AM_PM <- stringr::word(newdata$Time, 2) # get the second word of 'Time' which will be AM or PM

# better solution
# https://stackoverflow.com/questions/7883806/parse-timestamp-with-a-m-p-m
# this will make it today's date and the current time zone by default
newdata$rawTime <- as.POSIXct(newdata$Time, format="%l:%M %p")

# Lesson #1: always enter times as 24 hour clock: HH:MM !!

# Now use that to add 12 hours to rawTime whenit is actually PM
# newdata$fixedTime <- ifelse(newdata$AM_PM =="PM", # if PM
#                             newdata$rawTime + (12 * 60 * 60), #  add 12 hours
#                             newdata$rawTime # otherwise don't
#                             ) 
newdata$fixedHMS <- hms::as_hms(newdata$rawTime) # make sure it is in H:M:S format

t <- table(newdata$Time, newdata$rawTime)
kableExtra::kable(t, caption = "Test time coding") %>%
  kable_styling()
Table 1.2: Test time coding
2020-05-18 00:00:00 2020-05-18 00:30:00 2020-05-18 01:00:00 2020-05-18 01:30:00 2020-05-18 02:00:00 2020-05-18 02:30:00 2020-05-18 03:00:00 2020-05-18 03:30:00 2020-05-18 04:00:00 2020-05-18 04:30:00 2020-05-18 05:00:00 2020-05-18 05:30:00 2020-05-18 06:00:00 2020-05-18 06:30:00 2020-05-18 07:00:00 2020-05-18 07:30:00 2020-05-18 08:00:00 2020-05-18 08:30:00 2020-05-18 09:00:00 2020-05-18 09:30:00 2020-05-18 10:00:00 2020-05-18 10:30:00 2020-05-18 11:00:00 2020-05-18 11:30:00 2020-05-18 12:00:00 2020-05-18 12:30:00 2020-05-18 13:00:00 2020-05-18 13:30:00 2020-05-18 14:00:00 2020-05-18 14:30:00 2020-05-18 15:00:00 2020-05-18 15:30:00 2020-05-18 16:00:00 2020-05-18 16:30:00 2020-05-18 17:00:00 2020-05-18 17:30:00 2020-05-18 18:00:00 2020-05-18 18:30:00 2020-05-18 19:00:00 2020-05-18 19:30:00 2020-05-18 20:00:00 2020-05-18 20:30:00 2020-05-18 21:00:00 2020-05-18 21:30:00 2020-05-18 22:00:00 2020-05-18 22:30:00 2020-05-18 23:00:00 2020-05-18 23:30:00
1:00 AM 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1:30 AM 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10:00 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0
10:30 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0
11:00 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0
11:30 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89
12:00 AM 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
12:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
12:30 AM 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
12:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2:00 AM 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2:30 AM 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3:00 AM 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3:30 AM 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4:00 AM 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4:30 AM 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5:00 AM 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0
5:30 AM 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0
6:00 AM 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0
6:30 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0
7:00 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0
7:30 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0
8:00 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0
8:30 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0
9:00 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9:00 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0
9:30 AM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9:30 PM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 89 0 0 0 0

2 Weekdays TUD

Here i am trying to seprate the data into days so i can analyse the activities.

#filter newdata dataframe by date using the dplyr

#creating a new dataframe "Monday"
monday <- dplyr::filter(newdata, Day == "Monday")
head(monday)
##   Village Household ID    Day    Time Activity Activity2
## 1   Fanga            2 Monday 3:00 AM Sleeping      <NA>
## 2   Fanga            2 Monday 3:30 AM Sleeping      <NA>
## 3   Fanga            2 Monday 4:00 AM Sleeping      <NA>
## 4   Fanga            2 Monday 4:30 AM Sleeping      <NA>
## 5   Fanga            2 Monday 5:00 AM Sleeping      <NA>
## 6   Fanga            2 Monday 5:30 AM Sleeping      <NA>
##               rawTime fixedHMS
## 1 2020-05-18 03:00:00 03:00:00
## 2 2020-05-18 03:30:00 03:30:00
## 3 2020-05-18 04:00:00 04:00:00
## 4 2020-05-18 04:30:00 04:30:00
## 5 2020-05-18 05:00:00 05:00:00
## 6 2020-05-18 05:30:00 05:30:00
#creating a new dataframe "Tuesday"
tuesday <- dplyr::filter(newdata, Day == "Tuesday")
head(tuesday)
##     Village Household ID     Day    Time Activity Activity2
## 1 Fangaloto            4 Tuesday 3:00 AM Sleeping      <NA>
## 2 Fangaloto            4 Tuesday 3:30 AM Sleeping      <NA>
## 3 Fangaloto            4 Tuesday 4:00 AM Sleeping      <NA>
## 4 Fangaloto            4 Tuesday 4:30 AM Sleeping      <NA>
## 5 Fangaloto            4 Tuesday 5:00 AM Sleeping      <NA>
## 6 Fangaloto            4 Tuesday 5:30 AM Sleeping      <NA>
##               rawTime fixedHMS
## 1 2020-05-18 03:00:00 03:00:00
## 2 2020-05-18 03:30:00 03:30:00
## 3 2020-05-18 04:00:00 04:00:00
## 4 2020-05-18 04:30:00 04:30:00
## 5 2020-05-18 05:00:00 05:00:00
## 6 2020-05-18 05:30:00 05:30:00
#creating a new dataframe "Wednesday"
wednesday <- dplyr::filter(newdata, Day == "Wednesday")
head(wednesday)
##     Village Household ID       Day    Time Activity Activity2
## 1 Fangaloto            7 Wednesday 3:00 AM Sleeping      <NA>
## 2 Fangaloto            7 Wednesday 3:30 AM Sleeping      <NA>
## 3 Fangaloto            7 Wednesday 4:00 AM Sleeping      <NA>
## 4 Fangaloto            7 Wednesday 4:30 AM Sleeping      <NA>
## 5 Fangaloto            7 Wednesday 5:00 AM Sleeping      <NA>
## 6 Fangaloto            7 Wednesday 5:30 AM Sleeping      <NA>
##               rawTime fixedHMS
## 1 2020-05-18 03:00:00 03:00:00
## 2 2020-05-18 03:30:00 03:30:00
## 3 2020-05-18 04:00:00 04:00:00
## 4 2020-05-18 04:30:00 04:30:00
## 5 2020-05-18 05:00:00 05:00:00
## 6 2020-05-18 05:30:00 05:30:00
#creating a new dataframe "Thursday"
thursday <- dplyr::filter(newdata, Day == "Thursday")
head(thursday)
##     Village Household ID      Day    Time Activity Activity2
## 1 Fangaloto            6 Thursday 3:00 AM Sleeping      <NA>
## 2 Fangaloto            6 Thursday 3:30 AM Sleeping      <NA>
## 3 Fangaloto            6 Thursday 4:00 AM Sleeping      <NA>
## 4 Fangaloto            6 Thursday 4:30 AM Sleeping      <NA>
## 5 Fangaloto            6 Thursday 5:00 AM Sleeping      <NA>
## 6 Fangaloto            6 Thursday 5:30 AM Sleeping      <NA>
##               rawTime fixedHMS
## 1 2020-05-18 03:00:00 03:00:00
## 2 2020-05-18 03:30:00 03:30:00
## 3 2020-05-18 04:00:00 04:00:00
## 4 2020-05-18 04:30:00 04:30:00
## 5 2020-05-18 05:00:00 05:00:00
## 6 2020-05-18 05:30:00 05:30:00
#creating a new dataframe "Friday"
friday <- dplyr::filter(newdata, Day == "Friday")
head(friday)
##   Village Household ID    Day    Time Activity Activity2
## 1    Fasi           15 Friday 3:00 AM Sleeping      <NA>
## 2    Fasi           15 Friday 3:30 AM Sleeping      <NA>
## 3    Fasi           15 Friday 4:00 AM Sleeping      <NA>
## 4    Fasi           15 Friday 4:30 AM Sleeping      <NA>
## 5    Fasi           15 Friday 5:00 AM Sleeping      <NA>
## 6    Fasi           15 Friday 5:30 AM Sleeping      <NA>
##               rawTime fixedHMS
## 1 2020-05-18 03:00:00 03:00:00
## 2 2020-05-18 03:30:00 03:30:00
## 3 2020-05-18 04:00:00 04:00:00
## 4 2020-05-18 04:30:00 04:30:00
## 5 2020-05-18 05:00:00 05:00:00
## 6 2020-05-18 05:30:00 05:30:00

3 Frequency of Activity per weekday

So im trying to sort out the coding for Monday so i can copy it for the rest of the weekdays. I’ve did a frequency and proportion of activities for Monday.

#Monday 

#frequency of Activities
freqA <- table(monday$Activity, exclude=NULL)
freqA
## 
##                               Breakfast 
##                                      16 
##                 Charging mobile devices 
##                                       1 
##                                  Church 
##                                       6 
##              Church (social activities) 
##                                       2 
##                                 Cooking 
##                                      31 
##                          Cooking (baby) 
##                                       1 
##                      Cooking (business) 
##                                       3 
##                         Cooking (lunch) 
##                                       1 
##                                  Dinner 
##                                      36 
##                        Driving (church) 
##                                       1 
##                     Driving (drop kids) 
##                                       2 
##                Driving (drop relatives) 
##                                       1 
##                          Driving (farm) 
##                                       1 
##                           Driving (gym) 
##                                       4 
##                          Driving (home) 
##                                      23 
##                  Driving (pick up kids) 
##                                       9 
##            Driving (visiting relatives) 
##                                      10 
##                          Driving (work) 
##                                      21 
##                    Exercise (Jog, walk) 
##                                       4 
##                         Family devotion 
##                                      12 
##       Family time (chatting, games etc) 
##                                       4 
##                                    Farm 
##                                       2 
##                         Feeding animals 
##                                       3 
##                         Getting dressed 
##                                      17 
##                  Getting dressed (kids) 
##                                       5 
##                                     Gym 
##                                      14 
##                                    Home 
##                                      24 
##                         Homework (kids) 
##                                      23 
##                                 Ironing 
##                                       7 
##                            Kids bedtime 
##                                       6 
##                                 Laundry 
##                                       2 
##                        Light meal/snack 
##                                       1 
##                   Listen to music/radio 
##                                       2 
##                  Mobile device (movies) 
##                                      26 
## Mobile devices (browsing, social media) 
##                                      18 
##                   Mobile devices (work) 
##                                      12 
##             Prepare kids bag for school 
##                                       1 
##                 Public transport (home) 
##                                       3 
##                 Public transport (work) 
##                                       2 
##                                 Reading 
##                                      10 
##                                    Rest 
##                                      18 
##                               Showering 
##                                      32 
##                                Sleeping 
##                                     467 
##                                 Tidy up 
##                                      13 
##           Turning off appliances/Lights 
##                                       2 
##                          Walking (home) 
##                                       2 
##                          Walking (work) 
##                                       4 
##                    Watching movies (TV) 
##                                      49 
##                                 Woke up 
##                                      32 
##                                    Work 
##                                     550
dim(freqA)
## [1] 50
#proportion of Activities
propA <- prop.table(freqA)*100
propA <- round(propA, digits=2)
propA
## 
##                               Breakfast 
##                                    1.04 
##                 Charging mobile devices 
##                                    0.07 
##                                  Church 
##                                    0.39 
##              Church (social activities) 
##                                    0.13 
##                                 Cooking 
##                                    2.02 
##                          Cooking (baby) 
##                                    0.07 
##                      Cooking (business) 
##                                    0.20 
##                         Cooking (lunch) 
##                                    0.07 
##                                  Dinner 
##                                    2.34 
##                        Driving (church) 
##                                    0.07 
##                     Driving (drop kids) 
##                                    0.13 
##                Driving (drop relatives) 
##                                    0.07 
##                          Driving (farm) 
##                                    0.07 
##                           Driving (gym) 
##                                    0.26 
##                          Driving (home) 
##                                    1.50 
##                  Driving (pick up kids) 
##                                    0.59 
##            Driving (visiting relatives) 
##                                    0.65 
##                          Driving (work) 
##                                    1.37 
##                    Exercise (Jog, walk) 
##                                    0.26 
##                         Family devotion 
##                                    0.78 
##       Family time (chatting, games etc) 
##                                    0.26 
##                                    Farm 
##                                    0.13 
##                         Feeding animals 
##                                    0.20 
##                         Getting dressed 
##                                    1.11 
##                  Getting dressed (kids) 
##                                    0.33 
##                                     Gym 
##                                    0.91 
##                                    Home 
##                                    1.56 
##                         Homework (kids) 
##                                    1.50 
##                                 Ironing 
##                                    0.46 
##                            Kids bedtime 
##                                    0.39 
##                                 Laundry 
##                                    0.13 
##                        Light meal/snack 
##                                    0.07 
##                   Listen to music/radio 
##                                    0.13 
##                  Mobile device (movies) 
##                                    1.69 
## Mobile devices (browsing, social media) 
##                                    1.17 
##                   Mobile devices (work) 
##                                    0.78 
##             Prepare kids bag for school 
##                                    0.07 
##                 Public transport (home) 
##                                    0.20 
##                 Public transport (work) 
##                                    0.13 
##                                 Reading 
##                                    0.65 
##                                    Rest 
##                                    1.17 
##                               Showering 
##                                    2.08 
##                                Sleeping 
##                                   30.40 
##                                 Tidy up 
##                                    0.85 
##           Turning off appliances/Lights 
##                                    0.13 
##                          Walking (home) 
##                                    0.13 
##                          Walking (work) 
##                                    0.26 
##                    Watching movies (TV) 
##                                    3.19 
##                                 Woke up 
##                                    2.08 
##                                    Work 
##                                   35.81
dim(propA)
## [1] 50
#creating table with binding
tableMon <- cbind(freqA, propA)
tableMon <- cbind(Gender = rownames(tableMon), tableMon)
rownames(tableMon) <- NULL
tableMon
##       Gender                                    freqA propA  
##  [1,] "Breakfast"                               "16"  "1.04" 
##  [2,] "Charging mobile devices"                 "1"   "0.07" 
##  [3,] "Church"                                  "6"   "0.39" 
##  [4,] "Church (social activities)"              "2"   "0.13" 
##  [5,] "Cooking"                                 "31"  "2.02" 
##  [6,] "Cooking (baby)"                          "1"   "0.07" 
##  [7,] "Cooking (business)"                      "3"   "0.2"  
##  [8,] "Cooking (lunch)"                         "1"   "0.07" 
##  [9,] "Dinner"                                  "36"  "2.34" 
## [10,] "Driving (church)"                        "1"   "0.07" 
## [11,] "Driving (drop kids)"                     "2"   "0.13" 
## [12,] "Driving (drop relatives)"                "1"   "0.07" 
## [13,] "Driving (farm)"                          "1"   "0.07" 
## [14,] "Driving (gym)"                           "4"   "0.26" 
## [15,] "Driving (home)"                          "23"  "1.5"  
## [16,] "Driving (pick up kids)"                  "9"   "0.59" 
## [17,] "Driving (visiting relatives)"            "10"  "0.65" 
## [18,] "Driving (work)"                          "21"  "1.37" 
## [19,] "Exercise (Jog, walk)"                    "4"   "0.26" 
## [20,] "Family devotion"                         "12"  "0.78" 
## [21,] "Family time (chatting, games etc)"       "4"   "0.26" 
## [22,] "Farm"                                    "2"   "0.13" 
## [23,] "Feeding animals"                         "3"   "0.2"  
## [24,] "Getting dressed"                         "17"  "1.11" 
## [25,] "Getting dressed (kids)"                  "5"   "0.33" 
## [26,] "Gym"                                     "14"  "0.91" 
## [27,] "Home"                                    "24"  "1.56" 
## [28,] "Homework (kids)"                         "23"  "1.5"  
## [29,] "Ironing"                                 "7"   "0.46" 
## [30,] "Kids bedtime"                            "6"   "0.39" 
## [31,] "Laundry"                                 "2"   "0.13" 
## [32,] "Light meal/snack"                        "1"   "0.07" 
## [33,] "Listen to music/radio"                   "2"   "0.13" 
## [34,] "Mobile device (movies)"                  "26"  "1.69" 
## [35,] "Mobile devices (browsing, social media)" "18"  "1.17" 
## [36,] "Mobile devices (work)"                   "12"  "0.78" 
## [37,] "Prepare kids bag for school"             "1"   "0.07" 
## [38,] "Public transport (home)"                 "3"   "0.2"  
## [39,] "Public transport (work)"                 "2"   "0.13" 
## [40,] "Reading"                                 "10"  "0.65" 
## [41,] "Rest"                                    "18"  "1.17" 
## [42,] "Showering"                               "32"  "2.08" 
## [43,] "Sleeping"                                "467" "30.4" 
## [44,] "Tidy up"                                 "13"  "0.85" 
## [45,] "Turning off appliances/Lights"           "2"   "0.13" 
## [46,] "Walking (home)"                          "2"   "0.13" 
## [47,] "Walking (work)"                          "4"   "0.26" 
## [48,] "Watching movies (TV)"                    "49"  "3.19" 
## [49,] "Woke up"                                 "32"  "2.08" 
## [50,] "Work"                                    "550" "35.81"
#rename column names
colnames(tableMon)[colnames(tableMon) == "freqA"] <- "Frequency"
colnames(tableMon)[colnames(tableMon) == "propA"] <- "Proportion (%)"
tableMon
##       Gender                                    Frequency Proportion (%)
##  [1,] "Breakfast"                               "16"      "1.04"        
##  [2,] "Charging mobile devices"                 "1"       "0.07"        
##  [3,] "Church"                                  "6"       "0.39"        
##  [4,] "Church (social activities)"              "2"       "0.13"        
##  [5,] "Cooking"                                 "31"      "2.02"        
##  [6,] "Cooking (baby)"                          "1"       "0.07"        
##  [7,] "Cooking (business)"                      "3"       "0.2"         
##  [8,] "Cooking (lunch)"                         "1"       "0.07"        
##  [9,] "Dinner"                                  "36"      "2.34"        
## [10,] "Driving (church)"                        "1"       "0.07"        
## [11,] "Driving (drop kids)"                     "2"       "0.13"        
## [12,] "Driving (drop relatives)"                "1"       "0.07"        
## [13,] "Driving (farm)"                          "1"       "0.07"        
## [14,] "Driving (gym)"                           "4"       "0.26"        
## [15,] "Driving (home)"                          "23"      "1.5"         
## [16,] "Driving (pick up kids)"                  "9"       "0.59"        
## [17,] "Driving (visiting relatives)"            "10"      "0.65"        
## [18,] "Driving (work)"                          "21"      "1.37"        
## [19,] "Exercise (Jog, walk)"                    "4"       "0.26"        
## [20,] "Family devotion"                         "12"      "0.78"        
## [21,] "Family time (chatting, games etc)"       "4"       "0.26"        
## [22,] "Farm"                                    "2"       "0.13"        
## [23,] "Feeding animals"                         "3"       "0.2"         
## [24,] "Getting dressed"                         "17"      "1.11"        
## [25,] "Getting dressed (kids)"                  "5"       "0.33"        
## [26,] "Gym"                                     "14"      "0.91"        
## [27,] "Home"                                    "24"      "1.56"        
## [28,] "Homework (kids)"                         "23"      "1.5"         
## [29,] "Ironing"                                 "7"       "0.46"        
## [30,] "Kids bedtime"                            "6"       "0.39"        
## [31,] "Laundry"                                 "2"       "0.13"        
## [32,] "Light meal/snack"                        "1"       "0.07"        
## [33,] "Listen to music/radio"                   "2"       "0.13"        
## [34,] "Mobile device (movies)"                  "26"      "1.69"        
## [35,] "Mobile devices (browsing, social media)" "18"      "1.17"        
## [36,] "Mobile devices (work)"                   "12"      "0.78"        
## [37,] "Prepare kids bag for school"             "1"       "0.07"        
## [38,] "Public transport (home)"                 "3"       "0.2"         
## [39,] "Public transport (work)"                 "2"       "0.13"        
## [40,] "Reading"                                 "10"      "0.65"        
## [41,] "Rest"                                    "18"      "1.17"        
## [42,] "Showering"                               "32"      "2.08"        
## [43,] "Sleeping"                                "467"     "30.4"        
## [44,] "Tidy up"                                 "13"      "0.85"        
## [45,] "Turning off appliances/Lights"           "2"       "0.13"        
## [46,] "Walking (home)"                          "2"       "0.13"        
## [47,] "Walking (work)"                          "4"       "0.26"        
## [48,] "Watching movies (TV)"                    "49"      "3.19"        
## [49,] "Woke up"                                 "32"      "2.08"        
## [50,] "Work"                                    "550"     "35.81"
#using kable extra to create better table format
tableMonday <- kable(tableMon)%>%
  kable_styling(bootstrap_options = "striped", full_width = F)

tableMonday
Gender Frequency Proportion (%)
Breakfast 16 1.04
Charging mobile devices 1 0.07
Church 6 0.39
Church (social activities) 2 0.13
Cooking 31 2.02
Cooking (baby) 1 0.07
Cooking (business) 3 0.2
Cooking (lunch) 1 0.07
Dinner 36 2.34
Driving (church) 1 0.07
Driving (drop kids) 2 0.13
Driving (drop relatives) 1 0.07
Driving (farm) 1 0.07
Driving (gym) 4 0.26
Driving (home) 23 1.5
Driving (pick up kids) 9 0.59
Driving (visiting relatives) 10 0.65
Driving (work) 21 1.37
Exercise (Jog, walk) 4 0.26
Family devotion 12 0.78
Family time (chatting, games etc) 4 0.26
Farm 2 0.13
Feeding animals 3 0.2
Getting dressed 17 1.11
Getting dressed (kids) 5 0.33
Gym 14 0.91
Home 24 1.56
Homework (kids) 23 1.5
Ironing 7 0.46
Kids bedtime 6 0.39
Laundry 2 0.13
Light meal/snack 1 0.07
Listen to music/radio 2 0.13
Mobile device (movies) 26 1.69
Mobile devices (browsing, social media) 18 1.17
Mobile devices (work) 12 0.78
Prepare kids bag for school 1 0.07
Public transport (home) 3 0.2
Public transport (work) 2 0.13
Reading 10 0.65
Rest 18 1.17
Showering 32 2.08
Sleeping 467 30.4
Tidy up 13 0.85
Turning off appliances/Lights 2 0.13
Walking (home) 2 0.13
Walking (work) 4 0.26
Watching movies (TV) 49 3.19
Woke up 32 2.08
Work 550 35.81
#Tueday

#frequency of Activities
freqTue <- table(tuesday$Activity, exclude=NULL)
freqTue
## 
##                               Breakfast 
##                                       5 
##                 Church (choir practice) 
##                                       2 
##              Church (social activities) 
##                                       5 
##                                 Cooking 
##                                      23 
##                                  Dinner 
##                                      24 
##                     Driving (drop kids) 
##                                       7 
##                Driving (drop relatives) 
##                                       2 
##                     Driving (free time) 
##                                       2 
##                          Driving (home) 
##                                       8 
##                  Driving (pick up kids) 
##                                      12 
##                          Driving (work) 
##                                      12 
##                    Exercise (Jog, walk) 
##                                       2 
##                         Family devotion 
##                                       1 
##       Family time (chatting, games etc) 
##                                       5 
##                         Feeding animals 
##                                       3 
##                         Getting dressed 
##                                      16 
##                  Getting dressed (kids) 
##                                       2 
##                                    Home 
##                                      18 
##                         Homework (kids) 
##                                       2 
##                                 Ironing 
##                                       6 
##                                    Kava 
##                                      13 
##                        Light meal/snack 
##                                       2 
##                   Listen to music/radio 
##                                       3 
##                                   Lunch 
##                                       2 
##                  Mobile device (movies) 
##                                       7 
## Mobile devices (browsing, social media) 
##                                      12 
##                  Mobile devices (games) 
##                                       4 
##                   Mobile devices (work) 
##                                      21 
##                 Public transport (home) 
##                                       5 
##               Public transport (school) 
##                                       2 
##                                 Reading 
##                                       4 
##                                    Rest 
##                                       7 
##                                  School 
##                                      23 
##                               Showering 
##                                      14 
##                                Sleeping 
##                                     263 
##                                Studying 
##                                       9 
##                                 Tidy up 
##                                      13 
##           Turning off appliances/Lights 
##                                       1 
##            Turning on appliances/lights 
##                                       1 
##                          Walking (home) 
##                                       2 
##                          Walking (Kava) 
##                                       1 
##                          Walking (work) 
##                                       4 
##                    Watching movies (TV) 
##                                      53 
##                                 Woke up 
##                                      19 
##                                    Work 
##                                     270
dim(freqTue)
## [1] 45
#proportion of Activities
propTue <- prop.table(freqTue)*100
propTue <- round(propTue, digits=2)
propTue
## 
##                               Breakfast 
##                                    0.55 
##                 Church (choir practice) 
##                                    0.22 
##              Church (social activities) 
##                                    0.55 
##                                 Cooking 
##                                    2.52 
##                                  Dinner 
##                                    2.63 
##                     Driving (drop kids) 
##                                    0.77 
##                Driving (drop relatives) 
##                                    0.22 
##                     Driving (free time) 
##                                    0.22 
##                          Driving (home) 
##                                    0.88 
##                  Driving (pick up kids) 
##                                    1.32 
##                          Driving (work) 
##                                    1.32 
##                    Exercise (Jog, walk) 
##                                    0.22 
##                         Family devotion 
##                                    0.11 
##       Family time (chatting, games etc) 
##                                    0.55 
##                         Feeding animals 
##                                    0.33 
##                         Getting dressed 
##                                    1.75 
##                  Getting dressed (kids) 
##                                    0.22 
##                                    Home 
##                                    1.97 
##                         Homework (kids) 
##                                    0.22 
##                                 Ironing 
##                                    0.66 
##                                    Kava 
##                                    1.43 
##                        Light meal/snack 
##                                    0.22 
##                   Listen to music/radio 
##                                    0.33 
##                                   Lunch 
##                                    0.22 
##                  Mobile device (movies) 
##                                    0.77 
## Mobile devices (browsing, social media) 
##                                    1.32 
##                  Mobile devices (games) 
##                                    0.44 
##                   Mobile devices (work) 
##                                    2.30 
##                 Public transport (home) 
##                                    0.55 
##               Public transport (school) 
##                                    0.22 
##                                 Reading 
##                                    0.44 
##                                    Rest 
##                                    0.77 
##                                  School 
##                                    2.52 
##                               Showering 
##                                    1.54 
##                                Sleeping 
##                                   28.84 
##                                Studying 
##                                    0.99 
##                                 Tidy up 
##                                    1.43 
##           Turning off appliances/Lights 
##                                    0.11 
##            Turning on appliances/lights 
##                                    0.11 
##                          Walking (home) 
##                                    0.22 
##                          Walking (Kava) 
##                                    0.11 
##                          Walking (work) 
##                                    0.44 
##                    Watching movies (TV) 
##                                    5.81 
##                                 Woke up 
##                                    2.08 
##                                    Work 
##                                   29.61
dim(propTue)
## [1] 45
#creating table with binding
tableTue <- cbind(freqTue, propTue)
tableTue <- cbind(Gender = rownames(tableTue), tableTue)
rownames(tableTue) <- NULL
tableTue
##       Gender                                    freqTue propTue
##  [1,] "Breakfast"                               "5"     "0.55" 
##  [2,] "Church (choir practice)"                 "2"     "0.22" 
##  [3,] "Church (social activities)"              "5"     "0.55" 
##  [4,] "Cooking"                                 "23"    "2.52" 
##  [5,] "Dinner"                                  "24"    "2.63" 
##  [6,] "Driving (drop kids)"                     "7"     "0.77" 
##  [7,] "Driving (drop relatives)"                "2"     "0.22" 
##  [8,] "Driving (free time)"                     "2"     "0.22" 
##  [9,] "Driving (home)"                          "8"     "0.88" 
## [10,] "Driving (pick up kids)"                  "12"    "1.32" 
## [11,] "Driving (work)"                          "12"    "1.32" 
## [12,] "Exercise (Jog, walk)"                    "2"     "0.22" 
## [13,] "Family devotion"                         "1"     "0.11" 
## [14,] "Family time (chatting, games etc)"       "5"     "0.55" 
## [15,] "Feeding animals"                         "3"     "0.33" 
## [16,] "Getting dressed"                         "16"    "1.75" 
## [17,] "Getting dressed (kids)"                  "2"     "0.22" 
## [18,] "Home"                                    "18"    "1.97" 
## [19,] "Homework (kids)"                         "2"     "0.22" 
## [20,] "Ironing"                                 "6"     "0.66" 
## [21,] "Kava"                                    "13"    "1.43" 
## [22,] "Light meal/snack"                        "2"     "0.22" 
## [23,] "Listen to music/radio"                   "3"     "0.33" 
## [24,] "Lunch"                                   "2"     "0.22" 
## [25,] "Mobile device (movies)"                  "7"     "0.77" 
## [26,] "Mobile devices (browsing, social media)" "12"    "1.32" 
## [27,] "Mobile devices (games)"                  "4"     "0.44" 
## [28,] "Mobile devices (work)"                   "21"    "2.3"  
## [29,] "Public transport (home)"                 "5"     "0.55" 
## [30,] "Public transport (school)"               "2"     "0.22" 
## [31,] "Reading"                                 "4"     "0.44" 
## [32,] "Rest"                                    "7"     "0.77" 
## [33,] "School"                                  "23"    "2.52" 
## [34,] "Showering"                               "14"    "1.54" 
## [35,] "Sleeping"                                "263"   "28.84"
## [36,] "Studying"                                "9"     "0.99" 
## [37,] "Tidy up"                                 "13"    "1.43" 
## [38,] "Turning off appliances/Lights"           "1"     "0.11" 
## [39,] "Turning on appliances/lights"            "1"     "0.11" 
## [40,] "Walking (home)"                          "2"     "0.22" 
## [41,] "Walking (Kava)"                          "1"     "0.11" 
## [42,] "Walking (work)"                          "4"     "0.44" 
## [43,] "Watching movies (TV)"                    "53"    "5.81" 
## [44,] "Woke up"                                 "19"    "2.08" 
## [45,] "Work"                                    "270"   "29.61"
#rename column names
colnames(tableTue)[colnames(tableTue) == "freqTue"] <- "Frequency"
colnames(tableTue)[colnames(tableTue) == "propTue"] <- "Proportion (%)"
tableTue
##       Gender                                    Frequency Proportion (%)
##  [1,] "Breakfast"                               "5"       "0.55"        
##  [2,] "Church (choir practice)"                 "2"       "0.22"        
##  [3,] "Church (social activities)"              "5"       "0.55"        
##  [4,] "Cooking"                                 "23"      "2.52"        
##  [5,] "Dinner"                                  "24"      "2.63"        
##  [6,] "Driving (drop kids)"                     "7"       "0.77"        
##  [7,] "Driving (drop relatives)"                "2"       "0.22"        
##  [8,] "Driving (free time)"                     "2"       "0.22"        
##  [9,] "Driving (home)"                          "8"       "0.88"        
## [10,] "Driving (pick up kids)"                  "12"      "1.32"        
## [11,] "Driving (work)"                          "12"      "1.32"        
## [12,] "Exercise (Jog, walk)"                    "2"       "0.22"        
## [13,] "Family devotion"                         "1"       "0.11"        
## [14,] "Family time (chatting, games etc)"       "5"       "0.55"        
## [15,] "Feeding animals"                         "3"       "0.33"        
## [16,] "Getting dressed"                         "16"      "1.75"        
## [17,] "Getting dressed (kids)"                  "2"       "0.22"        
## [18,] "Home"                                    "18"      "1.97"        
## [19,] "Homework (kids)"                         "2"       "0.22"        
## [20,] "Ironing"                                 "6"       "0.66"        
## [21,] "Kava"                                    "13"      "1.43"        
## [22,] "Light meal/snack"                        "2"       "0.22"        
## [23,] "Listen to music/radio"                   "3"       "0.33"        
## [24,] "Lunch"                                   "2"       "0.22"        
## [25,] "Mobile device (movies)"                  "7"       "0.77"        
## [26,] "Mobile devices (browsing, social media)" "12"      "1.32"        
## [27,] "Mobile devices (games)"                  "4"       "0.44"        
## [28,] "Mobile devices (work)"                   "21"      "2.3"         
## [29,] "Public transport (home)"                 "5"       "0.55"        
## [30,] "Public transport (school)"               "2"       "0.22"        
## [31,] "Reading"                                 "4"       "0.44"        
## [32,] "Rest"                                    "7"       "0.77"        
## [33,] "School"                                  "23"      "2.52"        
## [34,] "Showering"                               "14"      "1.54"        
## [35,] "Sleeping"                                "263"     "28.84"       
## [36,] "Studying"                                "9"       "0.99"        
## [37,] "Tidy up"                                 "13"      "1.43"        
## [38,] "Turning off appliances/Lights"           "1"       "0.11"        
## [39,] "Turning on appliances/lights"            "1"       "0.11"        
## [40,] "Walking (home)"                          "2"       "0.22"        
## [41,] "Walking (Kava)"                          "1"       "0.11"        
## [42,] "Walking (work)"                          "4"       "0.44"        
## [43,] "Watching movies (TV)"                    "53"      "5.81"        
## [44,] "Woke up"                                 "19"      "2.08"        
## [45,] "Work"                                    "270"     "29.61"
#using kable extra to create better table format
tableTuesday <- kable(tableTue)%>%
  kable_styling(bootstrap_options = "striped", full_width = F)

tableTuesday
Gender Frequency Proportion (%)
Breakfast 5 0.55
Church (choir practice) 2 0.22
Church (social activities) 5 0.55
Cooking 23 2.52
Dinner 24 2.63
Driving (drop kids) 7 0.77
Driving (drop relatives) 2 0.22
Driving (free time) 2 0.22
Driving (home) 8 0.88
Driving (pick up kids) 12 1.32
Driving (work) 12 1.32
Exercise (Jog, walk) 2 0.22
Family devotion 1 0.11
Family time (chatting, games etc) 5 0.55
Feeding animals 3 0.33
Getting dressed 16 1.75
Getting dressed (kids) 2 0.22
Home 18 1.97
Homework (kids) 2 0.22
Ironing 6 0.66
Kava 13 1.43
Light meal/snack 2 0.22
Listen to music/radio 3 0.33
Lunch 2 0.22
Mobile device (movies) 7 0.77
Mobile devices (browsing, social media) 12 1.32
Mobile devices (games) 4 0.44
Mobile devices (work) 21 2.3
Public transport (home) 5 0.55
Public transport (school) 2 0.22
Reading 4 0.44
Rest 7 0.77
School 23 2.52
Showering 14 1.54
Sleeping 263 28.84
Studying 9 0.99
Tidy up 13 1.43
Turning off appliances/Lights 1 0.11
Turning on appliances/lights 1 0.11
Walking (home) 2 0.22
Walking (Kava) 1 0.11
Walking (work) 4 0.44
Watching movies (TV) 53 5.81
Woke up 19 2.08
Work 270 29.61
#Wednesday
#frequency of Activities
freqWed <- table(wednesday$Activity, exclude=NULL)
freqWed
## 
##                             Babysitting 
##                                       5 
##                               Breakfast 
##                                       8 
##                                  Church 
##                                       1 
##                                 Cooking 
##                                      26 
##                                  Dinner 
##                                      17 
##                           Driving (gym) 
##                                       4 
##                          Driving (home) 
##                                       8 
##                Driving (order delivery) 
##                                       9 
##                          Driving (work) 
##                                      13 
##                    Exercise (Jog, walk) 
##                                       3 
##                         Family devotion 
##                                       5 
##       Family time (chatting, games etc) 
##                                      19 
##                         Feeding animals 
##                                       6 
##                               Gardening 
##                                       2 
##                         Getting dressed 
##                                       7 
##                               Going out 
##                                       7 
##                                     Gym 
##                                      12 
##                                    Home 
##                                      14 
##                         Homework (kids) 
##                                       5 
##                                 Ironing 
##                                       2 
##                            Kids bedtime 
##                                       1 
##                                 Laundry 
##                                      13 
##                  Mobile device (movies) 
##                                       1 
## Mobile devices (browsing, social media) 
##                                       4 
##                   Mobile devices (work) 
##                                       2 
##                                 Reading 
##                                       7 
##                                    Rest 
##                                       7 
##                               Showering 
##                                      18 
##                        Showering (kids) 
##                                       1 
##                                Sleeping 
##                                     211 
##                                 Tidy up 
##                                       8 
##           Turning off appliances/Lights 
##                                       1 
##                          Walking (work) 
##                                       2 
##                    Watching movies (TV) 
##                                      23 
##                                 Woke up 
##                                      14 
##                                    Work 
##                                     234
dim(freqWed)
## [1] 36
#proportion of Activities
propWed <- prop.table(freqWed)*100
propWed <- round(propWed, digits=2)
propWed
## 
##                             Babysitting 
##                                    0.69 
##                               Breakfast 
##                                    1.11 
##                                  Church 
##                                    0.14 
##                                 Cooking 
##                                    3.61 
##                                  Dinner 
##                                    2.36 
##                           Driving (gym) 
##                                    0.56 
##                          Driving (home) 
##                                    1.11 
##                Driving (order delivery) 
##                                    1.25 
##                          Driving (work) 
##                                    1.81 
##                    Exercise (Jog, walk) 
##                                    0.42 
##                         Family devotion 
##                                    0.69 
##       Family time (chatting, games etc) 
##                                    2.64 
##                         Feeding animals 
##                                    0.83 
##                               Gardening 
##                                    0.28 
##                         Getting dressed 
##                                    0.97 
##                               Going out 
##                                    0.97 
##                                     Gym 
##                                    1.67 
##                                    Home 
##                                    1.94 
##                         Homework (kids) 
##                                    0.69 
##                                 Ironing 
##                                    0.28 
##                            Kids bedtime 
##                                    0.14 
##                                 Laundry 
##                                    1.81 
##                  Mobile device (movies) 
##                                    0.14 
## Mobile devices (browsing, social media) 
##                                    0.56 
##                   Mobile devices (work) 
##                                    0.28 
##                                 Reading 
##                                    0.97 
##                                    Rest 
##                                    0.97 
##                               Showering 
##                                    2.50 
##                        Showering (kids) 
##                                    0.14 
##                                Sleeping 
##                                   29.31 
##                                 Tidy up 
##                                    1.11 
##           Turning off appliances/Lights 
##                                    0.14 
##                          Walking (work) 
##                                    0.28 
##                    Watching movies (TV) 
##                                    3.19 
##                                 Woke up 
##                                    1.94 
##                                    Work 
##                                   32.50
dim(propWed)
## [1] 36
#creating table with binding
tableWed <- cbind(freqWed, propWed)
tableWed <- cbind(Gender = rownames(tableWed), tableWed)
rownames(tableWed) <- NULL
tableWed
##       Gender                                    freqWed propWed
##  [1,] "Babysitting"                             "5"     "0.69" 
##  [2,] "Breakfast"                               "8"     "1.11" 
##  [3,] "Church"                                  "1"     "0.14" 
##  [4,] "Cooking"                                 "26"    "3.61" 
##  [5,] "Dinner"                                  "17"    "2.36" 
##  [6,] "Driving (gym)"                           "4"     "0.56" 
##  [7,] "Driving (home)"                          "8"     "1.11" 
##  [8,] "Driving (order delivery)"                "9"     "1.25" 
##  [9,] "Driving (work)"                          "13"    "1.81" 
## [10,] "Exercise (Jog, walk)"                    "3"     "0.42" 
## [11,] "Family devotion"                         "5"     "0.69" 
## [12,] "Family time (chatting, games etc)"       "19"    "2.64" 
## [13,] "Feeding animals"                         "6"     "0.83" 
## [14,] "Gardening"                               "2"     "0.28" 
## [15,] "Getting dressed"                         "7"     "0.97" 
## [16,] "Going out"                               "7"     "0.97" 
## [17,] "Gym"                                     "12"    "1.67" 
## [18,] "Home"                                    "14"    "1.94" 
## [19,] "Homework (kids)"                         "5"     "0.69" 
## [20,] "Ironing"                                 "2"     "0.28" 
## [21,] "Kids bedtime"                            "1"     "0.14" 
## [22,] "Laundry"                                 "13"    "1.81" 
## [23,] "Mobile device (movies)"                  "1"     "0.14" 
## [24,] "Mobile devices (browsing, social media)" "4"     "0.56" 
## [25,] "Mobile devices (work)"                   "2"     "0.28" 
## [26,] "Reading"                                 "7"     "0.97" 
## [27,] "Rest"                                    "7"     "0.97" 
## [28,] "Showering"                               "18"    "2.5"  
## [29,] "Showering (kids)"                        "1"     "0.14" 
## [30,] "Sleeping"                                "211"   "29.31"
## [31,] "Tidy up"                                 "8"     "1.11" 
## [32,] "Turning off appliances/Lights"           "1"     "0.14" 
## [33,] "Walking (work)"                          "2"     "0.28" 
## [34,] "Watching movies (TV)"                    "23"    "3.19" 
## [35,] "Woke up"                                 "14"    "1.94" 
## [36,] "Work"                                    "234"   "32.5"
#rename column names
colnames(tableWed)[colnames(tableWed) == "freqWed"] <- "Frequency"
colnames(tableWed)[colnames(tableWed) == "propWed"] <- "Proportion (%)"
tableWed
##       Gender                                    Frequency Proportion (%)
##  [1,] "Babysitting"                             "5"       "0.69"        
##  [2,] "Breakfast"                               "8"       "1.11"        
##  [3,] "Church"                                  "1"       "0.14"        
##  [4,] "Cooking"                                 "26"      "3.61"        
##  [5,] "Dinner"                                  "17"      "2.36"        
##  [6,] "Driving (gym)"                           "4"       "0.56"        
##  [7,] "Driving (home)"                          "8"       "1.11"        
##  [8,] "Driving (order delivery)"                "9"       "1.25"        
##  [9,] "Driving (work)"                          "13"      "1.81"        
## [10,] "Exercise (Jog, walk)"                    "3"       "0.42"        
## [11,] "Family devotion"                         "5"       "0.69"        
## [12,] "Family time (chatting, games etc)"       "19"      "2.64"        
## [13,] "Feeding animals"                         "6"       "0.83"        
## [14,] "Gardening"                               "2"       "0.28"        
## [15,] "Getting dressed"                         "7"       "0.97"        
## [16,] "Going out"                               "7"       "0.97"        
## [17,] "Gym"                                     "12"      "1.67"        
## [18,] "Home"                                    "14"      "1.94"        
## [19,] "Homework (kids)"                         "5"       "0.69"        
## [20,] "Ironing"                                 "2"       "0.28"        
## [21,] "Kids bedtime"                            "1"       "0.14"        
## [22,] "Laundry"                                 "13"      "1.81"        
## [23,] "Mobile device (movies)"                  "1"       "0.14"        
## [24,] "Mobile devices (browsing, social media)" "4"       "0.56"        
## [25,] "Mobile devices (work)"                   "2"       "0.28"        
## [26,] "Reading"                                 "7"       "0.97"        
## [27,] "Rest"                                    "7"       "0.97"        
## [28,] "Showering"                               "18"      "2.5"         
## [29,] "Showering (kids)"                        "1"       "0.14"        
## [30,] "Sleeping"                                "211"     "29.31"       
## [31,] "Tidy up"                                 "8"       "1.11"        
## [32,] "Turning off appliances/Lights"           "1"       "0.14"        
## [33,] "Walking (work)"                          "2"       "0.28"        
## [34,] "Watching movies (TV)"                    "23"      "3.19"        
## [35,] "Woke up"                                 "14"      "1.94"        
## [36,] "Work"                                    "234"     "32.5"
#using kable extra to create better table format
tableWednesday <- kable(tableWed)%>%
  kable_styling(bootstrap_options = "striped", full_width = F)

tableWednesday
Gender Frequency Proportion (%)
Babysitting 5 0.69
Breakfast 8 1.11
Church 1 0.14
Cooking 26 3.61
Dinner 17 2.36
Driving (gym) 4 0.56
Driving (home) 8 1.11
Driving (order delivery) 9 1.25
Driving (work) 13 1.81
Exercise (Jog, walk) 3 0.42
Family devotion 5 0.69
Family time (chatting, games etc) 19 2.64
Feeding animals 6 0.83
Gardening 2 0.28
Getting dressed 7 0.97
Going out 7 0.97
Gym 12 1.67
Home 14 1.94
Homework (kids) 5 0.69
Ironing 2 0.28
Kids bedtime 1 0.14
Laundry 13 1.81
Mobile device (movies) 1 0.14
Mobile devices (browsing, social media) 4 0.56
Mobile devices (work) 2 0.28
Reading 7 0.97
Rest 7 0.97
Showering 18 2.5
Showering (kids) 1 0.14
Sleeping 211 29.31
Tidy up 8 1.11
Turning off appliances/Lights 1 0.14
Walking (work) 2 0.28
Watching movies (TV) 23 3.19
Woke up 14 1.94
Work 234 32.5
#Thursday
#frequency of Activities
freqThu <- table(thursday$Activity, exclude=NULL)
freqThu
## 
##                               Breakfast 
##                                       4 
##              Church (social activities) 
##                                       7 
##                                 Cooking 
##                                       6 
##                      Cooking (business) 
##                                       3 
##                         Cooking (lunch) 
##                                       1 
##                                  Dinner 
##                                       8 
##                        Driving (church) 
##                                       1 
##                     Driving (drop kids) 
##                                       1 
##                           Driving (gym) 
##                                       2 
##                          Driving (home) 
##                                       4 
##                Driving (order delivery) 
##                                       5 
##                  Driving (pick up kids) 
##                                       1 
##                          Driving (work) 
##                                       4 
##                    Exercise (Jog, walk) 
##                                       3 
##                         Family devotion 
##                                       3 
##       Family time (chatting, games etc) 
##                                       1 
##                    Food prep (business) 
##                                       3 
##                               Gardening 
##                                       2 
##                         Getting dressed 
##                                       6 
##                  Getting dressed (kids) 
##                                       1 
##                                     Gym 
##                                       6 
##                                    Home 
##                                       8 
##                         Homework (kids) 
##                                       3 
##                                 Laundry 
##                                       2 
##                   Listen to music/radio 
##                                       9 
##                                   Lunch 
##                                       1 
##                  Mobile device (movies) 
##                                       5 
## Mobile devices (browsing, social media) 
##                                       5 
##                   Mobile devices (work) 
##                                       6 
##                                 Reading 
##                                       1 
##                                    Rest 
##                                       9 
##                                  School 
##                                       5 
##                         Scripture study 
##                                       1 
##                               Showering 
##                                       7 
##                        Showering (kids) 
##                                       2 
##                                Sleeping 
##                                     108 
##                                 Tidy up 
##                                      11 
##                          Walking (work) 
##                                       1 
##                                 Woke up 
##                                       8 
##                                    Work 
##                                     120
dim(freqThu)
## [1] 40
#proportion of Activities
propThu <- prop.table(freqThu)*100
propThu <- round(propThu, digits=2)
propThu
## 
##                               Breakfast 
##                                    1.04 
##              Church (social activities) 
##                                    1.82 
##                                 Cooking 
##                                    1.56 
##                      Cooking (business) 
##                                    0.78 
##                         Cooking (lunch) 
##                                    0.26 
##                                  Dinner 
##                                    2.08 
##                        Driving (church) 
##                                    0.26 
##                     Driving (drop kids) 
##                                    0.26 
##                           Driving (gym) 
##                                    0.52 
##                          Driving (home) 
##                                    1.04 
##                Driving (order delivery) 
##                                    1.30 
##                  Driving (pick up kids) 
##                                    0.26 
##                          Driving (work) 
##                                    1.04 
##                    Exercise (Jog, walk) 
##                                    0.78 
##                         Family devotion 
##                                    0.78 
##       Family time (chatting, games etc) 
##                                    0.26 
##                    Food prep (business) 
##                                    0.78 
##                               Gardening 
##                                    0.52 
##                         Getting dressed 
##                                    1.56 
##                  Getting dressed (kids) 
##                                    0.26 
##                                     Gym 
##                                    1.56 
##                                    Home 
##                                    2.08 
##                         Homework (kids) 
##                                    0.78 
##                                 Laundry 
##                                    0.52 
##                   Listen to music/radio 
##                                    2.34 
##                                   Lunch 
##                                    0.26 
##                  Mobile device (movies) 
##                                    1.30 
## Mobile devices (browsing, social media) 
##                                    1.30 
##                   Mobile devices (work) 
##                                    1.56 
##                                 Reading 
##                                    0.26 
##                                    Rest 
##                                    2.34 
##                                  School 
##                                    1.30 
##                         Scripture study 
##                                    0.26 
##                               Showering 
##                                    1.82 
##                        Showering (kids) 
##                                    0.52 
##                                Sleeping 
##                                   28.12 
##                                 Tidy up 
##                                    2.86 
##                          Walking (work) 
##                                    0.26 
##                                 Woke up 
##                                    2.08 
##                                    Work 
##                                   31.25
dim(propThu)
## [1] 40
#creating table with binding
tableThu <- cbind(freqThu, propThu)
tableThu <- cbind(Gender = rownames(tableThu), tableThu)
rownames(tableThu) <- NULL
tableThu
##       Gender                                    freqThu propThu
##  [1,] "Breakfast"                               "4"     "1.04" 
##  [2,] "Church (social activities)"              "7"     "1.82" 
##  [3,] "Cooking"                                 "6"     "1.56" 
##  [4,] "Cooking (business)"                      "3"     "0.78" 
##  [5,] "Cooking (lunch)"                         "1"     "0.26" 
##  [6,] "Dinner"                                  "8"     "2.08" 
##  [7,] "Driving (church)"                        "1"     "0.26" 
##  [8,] "Driving (drop kids)"                     "1"     "0.26" 
##  [9,] "Driving (gym)"                           "2"     "0.52" 
## [10,] "Driving (home)"                          "4"     "1.04" 
## [11,] "Driving (order delivery)"                "5"     "1.3"  
## [12,] "Driving (pick up kids)"                  "1"     "0.26" 
## [13,] "Driving (work)"                          "4"     "1.04" 
## [14,] "Exercise (Jog, walk)"                    "3"     "0.78" 
## [15,] "Family devotion"                         "3"     "0.78" 
## [16,] "Family time (chatting, games etc)"       "1"     "0.26" 
## [17,] "Food prep (business)"                    "3"     "0.78" 
## [18,] "Gardening"                               "2"     "0.52" 
## [19,] "Getting dressed"                         "6"     "1.56" 
## [20,] "Getting dressed (kids)"                  "1"     "0.26" 
## [21,] "Gym"                                     "6"     "1.56" 
## [22,] "Home"                                    "8"     "2.08" 
## [23,] "Homework (kids)"                         "3"     "0.78" 
## [24,] "Laundry"                                 "2"     "0.52" 
## [25,] "Listen to music/radio"                   "9"     "2.34" 
## [26,] "Lunch"                                   "1"     "0.26" 
## [27,] "Mobile device (movies)"                  "5"     "1.3"  
## [28,] "Mobile devices (browsing, social media)" "5"     "1.3"  
## [29,] "Mobile devices (work)"                   "6"     "1.56" 
## [30,] "Reading"                                 "1"     "0.26" 
## [31,] "Rest"                                    "9"     "2.34" 
## [32,] "School"                                  "5"     "1.3"  
## [33,] "Scripture study"                         "1"     "0.26" 
## [34,] "Showering"                               "7"     "1.82" 
## [35,] "Showering (kids)"                        "2"     "0.52" 
## [36,] "Sleeping"                                "108"   "28.12"
## [37,] "Tidy up"                                 "11"    "2.86" 
## [38,] "Walking (work)"                          "1"     "0.26" 
## [39,] "Woke up"                                 "8"     "2.08" 
## [40,] "Work"                                    "120"   "31.25"
#rename column names
colnames(tableThu)[colnames(tableThu) == "freqThu"] <- "Frequency"
colnames(tableThu)[colnames(tableThu) == "propThu"] <- "Proportion (%)"
tableThu
##       Gender                                    Frequency Proportion (%)
##  [1,] "Breakfast"                               "4"       "1.04"        
##  [2,] "Church (social activities)"              "7"       "1.82"        
##  [3,] "Cooking"                                 "6"       "1.56"        
##  [4,] "Cooking (business)"                      "3"       "0.78"        
##  [5,] "Cooking (lunch)"                         "1"       "0.26"        
##  [6,] "Dinner"                                  "8"       "2.08"        
##  [7,] "Driving (church)"                        "1"       "0.26"        
##  [8,] "Driving (drop kids)"                     "1"       "0.26"        
##  [9,] "Driving (gym)"                           "2"       "0.52"        
## [10,] "Driving (home)"                          "4"       "1.04"        
## [11,] "Driving (order delivery)"                "5"       "1.3"         
## [12,] "Driving (pick up kids)"                  "1"       "0.26"        
## [13,] "Driving (work)"                          "4"       "1.04"        
## [14,] "Exercise (Jog, walk)"                    "3"       "0.78"        
## [15,] "Family devotion"                         "3"       "0.78"        
## [16,] "Family time (chatting, games etc)"       "1"       "0.26"        
## [17,] "Food prep (business)"                    "3"       "0.78"        
## [18,] "Gardening"                               "2"       "0.52"        
## [19,] "Getting dressed"                         "6"       "1.56"        
## [20,] "Getting dressed (kids)"                  "1"       "0.26"        
## [21,] "Gym"                                     "6"       "1.56"        
## [22,] "Home"                                    "8"       "2.08"        
## [23,] "Homework (kids)"                         "3"       "0.78"        
## [24,] "Laundry"                                 "2"       "0.52"        
## [25,] "Listen to music/radio"                   "9"       "2.34"        
## [26,] "Lunch"                                   "1"       "0.26"        
## [27,] "Mobile device (movies)"                  "5"       "1.3"         
## [28,] "Mobile devices (browsing, social media)" "5"       "1.3"         
## [29,] "Mobile devices (work)"                   "6"       "1.56"        
## [30,] "Reading"                                 "1"       "0.26"        
## [31,] "Rest"                                    "9"       "2.34"        
## [32,] "School"                                  "5"       "1.3"         
## [33,] "Scripture study"                         "1"       "0.26"        
## [34,] "Showering"                               "7"       "1.82"        
## [35,] "Showering (kids)"                        "2"       "0.52"        
## [36,] "Sleeping"                                "108"     "28.12"       
## [37,] "Tidy up"                                 "11"      "2.86"        
## [38,] "Walking (work)"                          "1"       "0.26"        
## [39,] "Woke up"                                 "8"       "2.08"        
## [40,] "Work"                                    "120"     "31.25"
#using kable extra to create better table format
tableThursday <- kable(tableThu)%>%
  kable_styling(bootstrap_options = "striped", full_width = F)

tableThursday
Gender Frequency Proportion (%)
Breakfast 4 1.04
Church (social activities) 7 1.82
Cooking 6 1.56
Cooking (business) 3 0.78
Cooking (lunch) 1 0.26
Dinner 8 2.08
Driving (church) 1 0.26
Driving (drop kids) 1 0.26
Driving (gym) 2 0.52
Driving (home) 4 1.04
Driving (order delivery) 5 1.3
Driving (pick up kids) 1 0.26
Driving (work) 4 1.04
Exercise (Jog, walk) 3 0.78
Family devotion 3 0.78
Family time (chatting, games etc) 1 0.26
Food prep (business) 3 0.78
Gardening 2 0.52
Getting dressed 6 1.56
Getting dressed (kids) 1 0.26
Gym 6 1.56
Home 8 2.08
Homework (kids) 3 0.78
Laundry 2 0.52
Listen to music/radio 9 2.34
Lunch 1 0.26
Mobile device (movies) 5 1.3
Mobile devices (browsing, social media) 5 1.3
Mobile devices (work) 6 1.56
Reading 1 0.26
Rest 9 2.34
School 5 1.3
Scripture study 1 0.26
Showering 7 1.82
Showering (kids) 2 0.52
Sleeping 108 28.12
Tidy up 11 2.86
Walking (work) 1 0.26
Woke up 8 2.08
Work 120 31.25
#Friday
#frequency of Activities
freqFri <- table(friday$Activity, exclude=NULL)
freqFri
## 
##                               Breakfast 
##                                       5 
##                                  Church 
##                                       1 
##                                 Cooking 
##                                      16 
##                                  Dinner 
##                                      15 
##                        Driving (church) 
##                                       1 
##                Driving (drop relatives) 
##                                       2 
##                          Driving (farm) 
##                                       4 
##                           Driving (gym) 
##                                       2 
##                          Driving (home) 
##                                       8 
##                          Driving (Kava) 
##                                       1 
##                          Driving (work) 
##                                       9 
##                         Family devotion 
##                                       4 
##       Family time (chatting, games etc) 
##                                       8 
##                                    Farm 
##                                      24 
##                         Feeding animals 
##                                       1 
##                         Getting dressed 
##                                      10 
##                                     Gym 
##                                       9 
##                                    Home 
##                                      15 
##                         Homework (kids) 
##                                       5 
##                                 Ironing 
##                                       6 
##                                    Kava 
##                                       6 
##                                 Laundry 
##                                       1 
##                  Mobile device (movies) 
##                                      18 
## Mobile devices (browsing, social media) 
##                                      12 
##                   Mobile devices (work) 
##                                      32 
##                                 Reading 
##                                       1 
##                                    Rest 
##                                       2 
##                       Scripture Reading 
##                                       1 
##                               showering 
##                                       1 
##                               Showering 
##                                      14 
##                                Sleeping 
##                                     219 
##                                 Tidy up 
##                                      12 
##                    Watching movies (TV) 
##                                      27 
##                                 Woke up 
##                                      15 
##                                    Work 
##                                     213
dim(freqFri)
## [1] 35
#proportion of Activities
propFri <- prop.table(freqFri)*100
propFri <- round(propFri, digits=2)
propFri
## 
##                               Breakfast 
##                                    0.69 
##                                  Church 
##                                    0.14 
##                                 Cooking 
##                                    2.22 
##                                  Dinner 
##                                    2.08 
##                        Driving (church) 
##                                    0.14 
##                Driving (drop relatives) 
##                                    0.28 
##                          Driving (farm) 
##                                    0.56 
##                           Driving (gym) 
##                                    0.28 
##                          Driving (home) 
##                                    1.11 
##                          Driving (Kava) 
##                                    0.14 
##                          Driving (work) 
##                                    1.25 
##                         Family devotion 
##                                    0.56 
##       Family time (chatting, games etc) 
##                                    1.11 
##                                    Farm 
##                                    3.33 
##                         Feeding animals 
##                                    0.14 
##                         Getting dressed 
##                                    1.39 
##                                     Gym 
##                                    1.25 
##                                    Home 
##                                    2.08 
##                         Homework (kids) 
##                                    0.69 
##                                 Ironing 
##                                    0.83 
##                                    Kava 
##                                    0.83 
##                                 Laundry 
##                                    0.14 
##                  Mobile device (movies) 
##                                    2.50 
## Mobile devices (browsing, social media) 
##                                    1.67 
##                   Mobile devices (work) 
##                                    4.44 
##                                 Reading 
##                                    0.14 
##                                    Rest 
##                                    0.28 
##                       Scripture Reading 
##                                    0.14 
##                               showering 
##                                    0.14 
##                               Showering 
##                                    1.94 
##                                Sleeping 
##                                   30.42 
##                                 Tidy up 
##                                    1.67 
##                    Watching movies (TV) 
##                                    3.75 
##                                 Woke up 
##                                    2.08 
##                                    Work 
##                                   29.58
dim(propFri)
## [1] 35
#creating table with binding
tableFri <- cbind(freqFri, propFri)
tableFri <- cbind(Gender = rownames(tableFri), tableFri)
rownames(tableFri) <- NULL
tableFri
##       Gender                                    freqFri propFri
##  [1,] "Breakfast"                               "5"     "0.69" 
##  [2,] "Church"                                  "1"     "0.14" 
##  [3,] "Cooking"                                 "16"    "2.22" 
##  [4,] "Dinner"                                  "15"    "2.08" 
##  [5,] "Driving (church)"                        "1"     "0.14" 
##  [6,] "Driving (drop relatives)"                "2"     "0.28" 
##  [7,] "Driving (farm)"                          "4"     "0.56" 
##  [8,] "Driving (gym)"                           "2"     "0.28" 
##  [9,] "Driving (home)"                          "8"     "1.11" 
## [10,] "Driving (Kava)"                          "1"     "0.14" 
## [11,] "Driving (work)"                          "9"     "1.25" 
## [12,] "Family devotion"                         "4"     "0.56" 
## [13,] "Family time (chatting, games etc)"       "8"     "1.11" 
## [14,] "Farm"                                    "24"    "3.33" 
## [15,] "Feeding animals"                         "1"     "0.14" 
## [16,] "Getting dressed"                         "10"    "1.39" 
## [17,] "Gym"                                     "9"     "1.25" 
## [18,] "Home"                                    "15"    "2.08" 
## [19,] "Homework (kids)"                         "5"     "0.69" 
## [20,] "Ironing"                                 "6"     "0.83" 
## [21,] "Kava"                                    "6"     "0.83" 
## [22,] "Laundry"                                 "1"     "0.14" 
## [23,] "Mobile device (movies)"                  "18"    "2.5"  
## [24,] "Mobile devices (browsing, social media)" "12"    "1.67" 
## [25,] "Mobile devices (work)"                   "32"    "4.44" 
## [26,] "Reading"                                 "1"     "0.14" 
## [27,] "Rest"                                    "2"     "0.28" 
## [28,] "Scripture Reading"                       "1"     "0.14" 
## [29,] "showering"                               "1"     "0.14" 
## [30,] "Showering"                               "14"    "1.94" 
## [31,] "Sleeping"                                "219"   "30.42"
## [32,] "Tidy up"                                 "12"    "1.67" 
## [33,] "Watching movies (TV)"                    "27"    "3.75" 
## [34,] "Woke up"                                 "15"    "2.08" 
## [35,] "Work"                                    "213"   "29.58"
#rename column names
colnames(tableFri)[colnames(tableFri) == "freqFri"] <- "Frequency"
colnames(tableFri)[colnames(tableFri) == "propFri"] <- "Proportion (%)"
tableFri
##       Gender                                    Frequency Proportion (%)
##  [1,] "Breakfast"                               "5"       "0.69"        
##  [2,] "Church"                                  "1"       "0.14"        
##  [3,] "Cooking"                                 "16"      "2.22"        
##  [4,] "Dinner"                                  "15"      "2.08"        
##  [5,] "Driving (church)"                        "1"       "0.14"        
##  [6,] "Driving (drop relatives)"                "2"       "0.28"        
##  [7,] "Driving (farm)"                          "4"       "0.56"        
##  [8,] "Driving (gym)"                           "2"       "0.28"        
##  [9,] "Driving (home)"                          "8"       "1.11"        
## [10,] "Driving (Kava)"                          "1"       "0.14"        
## [11,] "Driving (work)"                          "9"       "1.25"        
## [12,] "Family devotion"                         "4"       "0.56"        
## [13,] "Family time (chatting, games etc)"       "8"       "1.11"        
## [14,] "Farm"                                    "24"      "3.33"        
## [15,] "Feeding animals"                         "1"       "0.14"        
## [16,] "Getting dressed"                         "10"      "1.39"        
## [17,] "Gym"                                     "9"       "1.25"        
## [18,] "Home"                                    "15"      "2.08"        
## [19,] "Homework (kids)"                         "5"       "0.69"        
## [20,] "Ironing"                                 "6"       "0.83"        
## [21,] "Kava"                                    "6"       "0.83"        
## [22,] "Laundry"                                 "1"       "0.14"        
## [23,] "Mobile device (movies)"                  "18"      "2.5"         
## [24,] "Mobile devices (browsing, social media)" "12"      "1.67"        
## [25,] "Mobile devices (work)"                   "32"      "4.44"        
## [26,] "Reading"                                 "1"       "0.14"        
## [27,] "Rest"                                    "2"       "0.28"        
## [28,] "Scripture Reading"                       "1"       "0.14"        
## [29,] "showering"                               "1"       "0.14"        
## [30,] "Showering"                               "14"      "1.94"        
## [31,] "Sleeping"                                "219"     "30.42"       
## [32,] "Tidy up"                                 "12"      "1.67"        
## [33,] "Watching movies (TV)"                    "27"      "3.75"        
## [34,] "Woke up"                                 "15"      "2.08"        
## [35,] "Work"                                    "213"     "29.58"
#using kable extra to create better table format
tableFriday <- kable(tableFri)%>%
  kable_styling(bootstrap_options = "striped", full_width = F)

tableFriday
Gender Frequency Proportion (%)
Breakfast 5 0.69
Church 1 0.14
Cooking 16 2.22
Dinner 15 2.08
Driving (church) 1 0.14
Driving (drop relatives) 2 0.28
Driving (farm) 4 0.56
Driving (gym) 2 0.28
Driving (home) 8 1.11
Driving (Kava) 1 0.14
Driving (work) 9 1.25
Family devotion 4 0.56
Family time (chatting, games etc) 8 1.11
Farm 24 3.33
Feeding animals 1 0.14
Getting dressed 10 1.39
Gym 9 1.25
Home 15 2.08
Homework (kids) 5 0.69
Ironing 6 0.83
Kava 6 0.83
Laundry 1 0.14
Mobile device (movies) 18 2.5
Mobile devices (browsing, social media) 12 1.67
Mobile devices (work) 32 4.44
Reading 1 0.14
Rest 2 0.28
Scripture Reading 1 0.14
showering 1 0.14
Showering 14 1.94
Sleeping 219 30.42
Tidy up 12 1.67
Watching movies (TV) 27 3.75
Woke up 15 2.08
Work 213 29.58
#weekdays
#frequency of Activities
freqwkd <- table(newdata$Activity, exclude=NULL)
freqwkd
## 
##                             Babysitting 
##                                       5 
##                               Breakfast 
##                                      38 
##                 Charging mobile devices 
##                                       1 
##                                  Church 
##                                       8 
##                 Church (choir practice) 
##                                       2 
##              Church (social activities) 
##                                      14 
##                                 Cooking 
##                                     102 
##                          Cooking (baby) 
##                                       1 
##                      Cooking (business) 
##                                       6 
##                         Cooking (lunch) 
##                                       2 
##                                  Dinner 
##                                     100 
##                        Driving (church) 
##                                       3 
##                     Driving (drop kids) 
##                                      10 
##                Driving (drop relatives) 
##                                       5 
##                          Driving (farm) 
##                                       5 
##                     Driving (free time) 
##                                       2 
##                           Driving (gym) 
##                                      12 
##                          Driving (home) 
##                                      51 
##                          Driving (Kava) 
##                                       1 
##                Driving (order delivery) 
##                                      14 
##                  Driving (pick up kids) 
##                                      22 
##            Driving (visiting relatives) 
##                                      10 
##                          Driving (work) 
##                                      59 
##                    Exercise (Jog, walk) 
##                                      12 
##                         Family devotion 
##                                      25 
##       Family time (chatting, games etc) 
##                                      37 
##                                    Farm 
##                                      26 
##                         Feeding animals 
##                                      13 
##                    Food prep (business) 
##                                       3 
##                               Gardening 
##                                       4 
##                         Getting dressed 
##                                      56 
##                  Getting dressed (kids) 
##                                       8 
##                               Going out 
##                                       7 
##                                     Gym 
##                                      41 
##                                    Home 
##                                      79 
##                         Homework (kids) 
##                                      38 
##                                 Ironing 
##                                      21 
##                                    Kava 
##                                      19 
##                            Kids bedtime 
##                                       7 
##                                 Laundry 
##                                      18 
##                        Light meal/snack 
##                                       3 
##                   Listen to music/radio 
##                                      14 
##                                   Lunch 
##                                       3 
##                  Mobile device (movies) 
##                                      57 
## Mobile devices (browsing, social media) 
##                                      51 
##                  Mobile devices (games) 
##                                       4 
##                   Mobile devices (work) 
##                                      73 
##             Prepare kids bag for school 
##                                       1 
##                 Public transport (home) 
##                                       8 
##               Public transport (school) 
##                                       2 
##                 Public transport (work) 
##                                       2 
##                                 Reading 
##                                      23 
##                                    Rest 
##                                      43 
##                                  School 
##                                      28 
##                       Scripture Reading 
##                                       1 
##                         Scripture study 
##                                       1 
##                               showering 
##                                       1 
##                               Showering 
##                                      85 
##                        Showering (kids) 
##                                       3 
##                                Sleeping 
##                                    1268 
##                                Studying 
##                                       9 
##                                 Tidy up 
##                                      57 
##           Turning off appliances/Lights 
##                                       4 
##            Turning on appliances/lights 
##                                       1 
##                          Walking (home) 
##                                       4 
##                          Walking (Kava) 
##                                       1 
##                          Walking (work) 
##                                      11 
##                    Watching movies (TV) 
##                                     152 
##                                 Woke up 
##                                      88 
##                                    Work 
##                                    1387
dim(freqwkd)
## [1] 70
#proportion of Activities
propwkd <- prop.table(freqwkd)*100
propwkd <- round(propwkd, digits=2)
propwkd
## 
##                             Babysitting 
##                                    0.12 
##                               Breakfast 
##                                    0.89 
##                 Charging mobile devices 
##                                    0.02 
##                                  Church 
##                                    0.19 
##                 Church (choir practice) 
##                                    0.05 
##              Church (social activities) 
##                                    0.33 
##                                 Cooking 
##                                    2.39 
##                          Cooking (baby) 
##                                    0.02 
##                      Cooking (business) 
##                                    0.14 
##                         Cooking (lunch) 
##                                    0.05 
##                                  Dinner 
##                                    2.34 
##                        Driving (church) 
##                                    0.07 
##                     Driving (drop kids) 
##                                    0.23 
##                Driving (drop relatives) 
##                                    0.12 
##                          Driving (farm) 
##                                    0.12 
##                     Driving (free time) 
##                                    0.05 
##                           Driving (gym) 
##                                    0.28 
##                          Driving (home) 
##                                    1.19 
##                          Driving (Kava) 
##                                    0.02 
##                Driving (order delivery) 
##                                    0.33 
##                  Driving (pick up kids) 
##                                    0.51 
##            Driving (visiting relatives) 
##                                    0.23 
##                          Driving (work) 
##                                    1.38 
##                    Exercise (Jog, walk) 
##                                    0.28 
##                         Family devotion 
##                                    0.59 
##       Family time (chatting, games etc) 
##                                    0.87 
##                                    Farm 
##                                    0.61 
##                         Feeding animals 
##                                    0.30 
##                    Food prep (business) 
##                                    0.07 
##                               Gardening 
##                                    0.09 
##                         Getting dressed 
##                                    1.31 
##                  Getting dressed (kids) 
##                                    0.19 
##                               Going out 
##                                    0.16 
##                                     Gym 
##                                    0.96 
##                                    Home 
##                                    1.85 
##                         Homework (kids) 
##                                    0.89 
##                                 Ironing 
##                                    0.49 
##                                    Kava 
##                                    0.44 
##                            Kids bedtime 
##                                    0.16 
##                                 Laundry 
##                                    0.42 
##                        Light meal/snack 
##                                    0.07 
##                   Listen to music/radio 
##                                    0.33 
##                                   Lunch 
##                                    0.07 
##                  Mobile device (movies) 
##                                    1.33 
## Mobile devices (browsing, social media) 
##                                    1.19 
##                  Mobile devices (games) 
##                                    0.09 
##                   Mobile devices (work) 
##                                    1.71 
##             Prepare kids bag for school 
##                                    0.02 
##                 Public transport (home) 
##                                    0.19 
##               Public transport (school) 
##                                    0.05 
##                 Public transport (work) 
##                                    0.05 
##                                 Reading 
##                                    0.54 
##                                    Rest 
##                                    1.01 
##                                  School 
##                                    0.66 
##                       Scripture Reading 
##                                    0.02 
##                         Scripture study 
##                                    0.02 
##                               showering 
##                                    0.02 
##                               Showering 
##                                    1.99 
##                        Showering (kids) 
##                                    0.07 
##                                Sleeping 
##                                   29.68 
##                                Studying 
##                                    0.21 
##                                 Tidy up 
##                                    1.33 
##           Turning off appliances/Lights 
##                                    0.09 
##            Turning on appliances/lights 
##                                    0.02 
##                          Walking (home) 
##                                    0.09 
##                          Walking (Kava) 
##                                    0.02 
##                          Walking (work) 
##                                    0.26 
##                    Watching movies (TV) 
##                                    3.56 
##                                 Woke up 
##                                    2.06 
##                                    Work 
##                                   32.47
dim(propwkd)
## [1] 70
#creating table with binding
tablewkd <- cbind(freqwkd, propwkd)
tablewkd <- cbind(Gender = rownames(tablewkd), tablewkd)
rownames(tablewkd) <- NULL
tablewkd
##       Gender                                    freqwkd propwkd
##  [1,] "Babysitting"                             "5"     "0.12" 
##  [2,] "Breakfast"                               "38"    "0.89" 
##  [3,] "Charging mobile devices"                 "1"     "0.02" 
##  [4,] "Church"                                  "8"     "0.19" 
##  [5,] "Church (choir practice)"                 "2"     "0.05" 
##  [6,] "Church (social activities)"              "14"    "0.33" 
##  [7,] "Cooking"                                 "102"   "2.39" 
##  [8,] "Cooking (baby)"                          "1"     "0.02" 
##  [9,] "Cooking (business)"                      "6"     "0.14" 
## [10,] "Cooking (lunch)"                         "2"     "0.05" 
## [11,] "Dinner"                                  "100"   "2.34" 
## [12,] "Driving (church)"                        "3"     "0.07" 
## [13,] "Driving (drop kids)"                     "10"    "0.23" 
## [14,] "Driving (drop relatives)"                "5"     "0.12" 
## [15,] "Driving (farm)"                          "5"     "0.12" 
## [16,] "Driving (free time)"                     "2"     "0.05" 
## [17,] "Driving (gym)"                           "12"    "0.28" 
## [18,] "Driving (home)"                          "51"    "1.19" 
## [19,] "Driving (Kava)"                          "1"     "0.02" 
## [20,] "Driving (order delivery)"                "14"    "0.33" 
## [21,] "Driving (pick up kids)"                  "22"    "0.51" 
## [22,] "Driving (visiting relatives)"            "10"    "0.23" 
## [23,] "Driving (work)"                          "59"    "1.38" 
## [24,] "Exercise (Jog, walk)"                    "12"    "0.28" 
## [25,] "Family devotion"                         "25"    "0.59" 
## [26,] "Family time (chatting, games etc)"       "37"    "0.87" 
## [27,] "Farm"                                    "26"    "0.61" 
## [28,] "Feeding animals"                         "13"    "0.3"  
## [29,] "Food prep (business)"                    "3"     "0.07" 
## [30,] "Gardening"                               "4"     "0.09" 
## [31,] "Getting dressed"                         "56"    "1.31" 
## [32,] "Getting dressed (kids)"                  "8"     "0.19" 
## [33,] "Going out"                               "7"     "0.16" 
## [34,] "Gym"                                     "41"    "0.96" 
## [35,] "Home"                                    "79"    "1.85" 
## [36,] "Homework (kids)"                         "38"    "0.89" 
## [37,] "Ironing"                                 "21"    "0.49" 
## [38,] "Kava"                                    "19"    "0.44" 
## [39,] "Kids bedtime"                            "7"     "0.16" 
## [40,] "Laundry"                                 "18"    "0.42" 
## [41,] "Light meal/snack"                        "3"     "0.07" 
## [42,] "Listen to music/radio"                   "14"    "0.33" 
## [43,] "Lunch"                                   "3"     "0.07" 
## [44,] "Mobile device (movies)"                  "57"    "1.33" 
## [45,] "Mobile devices (browsing, social media)" "51"    "1.19" 
## [46,] "Mobile devices (games)"                  "4"     "0.09" 
## [47,] "Mobile devices (work)"                   "73"    "1.71" 
## [48,] "Prepare kids bag for school"             "1"     "0.02" 
## [49,] "Public transport (home)"                 "8"     "0.19" 
## [50,] "Public transport (school)"               "2"     "0.05" 
## [51,] "Public transport (work)"                 "2"     "0.05" 
## [52,] "Reading"                                 "23"    "0.54" 
## [53,] "Rest"                                    "43"    "1.01" 
## [54,] "School"                                  "28"    "0.66" 
## [55,] "Scripture Reading"                       "1"     "0.02" 
## [56,] "Scripture study"                         "1"     "0.02" 
## [57,] "showering"                               "1"     "0.02" 
## [58,] "Showering"                               "85"    "1.99" 
## [59,] "Showering (kids)"                        "3"     "0.07" 
## [60,] "Sleeping"                                "1268"  "29.68"
## [61,] "Studying"                                "9"     "0.21" 
## [62,] "Tidy up"                                 "57"    "1.33" 
## [63,] "Turning off appliances/Lights"           "4"     "0.09" 
## [64,] "Turning on appliances/lights"            "1"     "0.02" 
## [65,] "Walking (home)"                          "4"     "0.09" 
## [66,] "Walking (Kava)"                          "1"     "0.02" 
## [67,] "Walking (work)"                          "11"    "0.26" 
## [68,] "Watching movies (TV)"                    "152"   "3.56" 
## [69,] "Woke up"                                 "88"    "2.06" 
## [70,] "Work"                                    "1387"  "32.47"
#rename column names
colnames(tablewkd)[colnames(tablewkd) == "freqwkd"] <- "Frequency"
colnames(tablewkd)[colnames(tableTue) == "propwkd"] <- "Proportion (%)"
tablewkd
##       Gender                                    Frequency propwkd
##  [1,] "Babysitting"                             "5"       "0.12" 
##  [2,] "Breakfast"                               "38"      "0.89" 
##  [3,] "Charging mobile devices"                 "1"       "0.02" 
##  [4,] "Church"                                  "8"       "0.19" 
##  [5,] "Church (choir practice)"                 "2"       "0.05" 
##  [6,] "Church (social activities)"              "14"      "0.33" 
##  [7,] "Cooking"                                 "102"     "2.39" 
##  [8,] "Cooking (baby)"                          "1"       "0.02" 
##  [9,] "Cooking (business)"                      "6"       "0.14" 
## [10,] "Cooking (lunch)"                         "2"       "0.05" 
## [11,] "Dinner"                                  "100"     "2.34" 
## [12,] "Driving (church)"                        "3"       "0.07" 
## [13,] "Driving (drop kids)"                     "10"      "0.23" 
## [14,] "Driving (drop relatives)"                "5"       "0.12" 
## [15,] "Driving (farm)"                          "5"       "0.12" 
## [16,] "Driving (free time)"                     "2"       "0.05" 
## [17,] "Driving (gym)"                           "12"      "0.28" 
## [18,] "Driving (home)"                          "51"      "1.19" 
## [19,] "Driving (Kava)"                          "1"       "0.02" 
## [20,] "Driving (order delivery)"                "14"      "0.33" 
## [21,] "Driving (pick up kids)"                  "22"      "0.51" 
## [22,] "Driving (visiting relatives)"            "10"      "0.23" 
## [23,] "Driving (work)"                          "59"      "1.38" 
## [24,] "Exercise (Jog, walk)"                    "12"      "0.28" 
## [25,] "Family devotion"                         "25"      "0.59" 
## [26,] "Family time (chatting, games etc)"       "37"      "0.87" 
## [27,] "Farm"                                    "26"      "0.61" 
## [28,] "Feeding animals"                         "13"      "0.3"  
## [29,] "Food prep (business)"                    "3"       "0.07" 
## [30,] "Gardening"                               "4"       "0.09" 
## [31,] "Getting dressed"                         "56"      "1.31" 
## [32,] "Getting dressed (kids)"                  "8"       "0.19" 
## [33,] "Going out"                               "7"       "0.16" 
## [34,] "Gym"                                     "41"      "0.96" 
## [35,] "Home"                                    "79"      "1.85" 
## [36,] "Homework (kids)"                         "38"      "0.89" 
## [37,] "Ironing"                                 "21"      "0.49" 
## [38,] "Kava"                                    "19"      "0.44" 
## [39,] "Kids bedtime"                            "7"       "0.16" 
## [40,] "Laundry"                                 "18"      "0.42" 
## [41,] "Light meal/snack"                        "3"       "0.07" 
## [42,] "Listen to music/radio"                   "14"      "0.33" 
## [43,] "Lunch"                                   "3"       "0.07" 
## [44,] "Mobile device (movies)"                  "57"      "1.33" 
## [45,] "Mobile devices (browsing, social media)" "51"      "1.19" 
## [46,] "Mobile devices (games)"                  "4"       "0.09" 
## [47,] "Mobile devices (work)"                   "73"      "1.71" 
## [48,] "Prepare kids bag for school"             "1"       "0.02" 
## [49,] "Public transport (home)"                 "8"       "0.19" 
## [50,] "Public transport (school)"               "2"       "0.05" 
## [51,] "Public transport (work)"                 "2"       "0.05" 
## [52,] "Reading"                                 "23"      "0.54" 
## [53,] "Rest"                                    "43"      "1.01" 
## [54,] "School"                                  "28"      "0.66" 
## [55,] "Scripture Reading"                       "1"       "0.02" 
## [56,] "Scripture study"                         "1"       "0.02" 
## [57,] "showering"                               "1"       "0.02" 
## [58,] "Showering"                               "85"      "1.99" 
## [59,] "Showering (kids)"                        "3"       "0.07" 
## [60,] "Sleeping"                                "1268"    "29.68"
## [61,] "Studying"                                "9"       "0.21" 
## [62,] "Tidy up"                                 "57"      "1.33" 
## [63,] "Turning off appliances/Lights"           "4"       "0.09" 
## [64,] "Turning on appliances/lights"            "1"       "0.02" 
## [65,] "Walking (home)"                          "4"       "0.09" 
## [66,] "Walking (Kava)"                          "1"       "0.02" 
## [67,] "Walking (work)"                          "11"      "0.26" 
## [68,] "Watching movies (TV)"                    "152"     "3.56" 
## [69,] "Woke up"                                 "88"      "2.06" 
## [70,] "Work"                                    "1387"    "32.47"
#using kable extra to create better table format
tableWeekdays <- kable(tablewkd)%>%
  kable_styling(bootstrap_options = "striped", full_width = F)

tableWeekdays
Gender Frequency propwkd
Babysitting 5 0.12
Breakfast 38 0.89
Charging mobile devices 1 0.02
Church 8 0.19
Church (choir practice) 2 0.05
Church (social activities) 14 0.33
Cooking 102 2.39
Cooking (baby) 1 0.02
Cooking (business) 6 0.14
Cooking (lunch) 2 0.05
Dinner 100 2.34
Driving (church) 3 0.07
Driving (drop kids) 10 0.23
Driving (drop relatives) 5 0.12
Driving (farm) 5 0.12
Driving (free time) 2 0.05
Driving (gym) 12 0.28
Driving (home) 51 1.19
Driving (Kava) 1 0.02
Driving (order delivery) 14 0.33
Driving (pick up kids) 22 0.51
Driving (visiting relatives) 10 0.23
Driving (work) 59 1.38
Exercise (Jog, walk) 12 0.28
Family devotion 25 0.59
Family time (chatting, games etc) 37 0.87
Farm 26 0.61
Feeding animals 13 0.3
Food prep (business) 3 0.07
Gardening 4 0.09
Getting dressed 56 1.31
Getting dressed (kids) 8 0.19
Going out 7 0.16
Gym 41 0.96
Home 79 1.85
Homework (kids) 38 0.89
Ironing 21 0.49
Kava 19 0.44
Kids bedtime 7 0.16
Laundry 18 0.42
Light meal/snack 3 0.07
Listen to music/radio 14 0.33
Lunch 3 0.07
Mobile device (movies) 57 1.33
Mobile devices (browsing, social media) 51 1.19
Mobile devices (games) 4 0.09
Mobile devices (work) 73 1.71
Prepare kids bag for school 1 0.02
Public transport (home) 8 0.19
Public transport (school) 2 0.05
Public transport (work) 2 0.05
Reading 23 0.54
Rest 43 1.01
School 28 0.66
Scripture Reading 1 0.02
Scripture study 1 0.02
showering 1 0.02
Showering 85 1.99
Showering (kids) 3 0.07
Sleeping 1268 29.68
Studying 9 0.21
Tidy up 57 1.33
Turning off appliances/Lights 4 0.09
Turning on appliances/lights 1 0.02
Walking (home) 4 0.09
Walking (Kava) 1 0.02
Walking (work) 11 0.26
Watching movies (TV) 152 3.56
Woke up 88 2.06
Work 1387 32.47

3.1 Weekdays Activities TUD

Im trying to see the count for all the activities in the TUD

#Monday
groupbymonAct <- monday %>%
  dplyr::group_by(Activity) %>%
  dplyr::summarize(count = n())
groupbymonAct
## # A tibble: 50 x 2
##    Activity                   count
##    <chr>                      <int>
##  1 Breakfast                     16
##  2 Charging mobile devices        1
##  3 Church                         6
##  4 Church (social activities)     2
##  5 Cooking                       31
##  6 Cooking (baby)                 1
##  7 Cooking (business)             3
##  8 Cooking (lunch)                1
##  9 Dinner                        36
## 10 Driving (church)               1
## # … with 40 more rows
#Tuesday
groupbytueAct <- tuesday %>%
  dplyr::group_by(Activity) %>%
  dplyr::summarize(count = n())
groupbytueAct
## # A tibble: 45 x 2
##    Activity                   count
##    <chr>                      <int>
##  1 Breakfast                      5
##  2 Church (choir practice)        2
##  3 Church (social activities)     5
##  4 Cooking                       23
##  5 Dinner                        24
##  6 Driving (drop kids)            7
##  7 Driving (drop relatives)       2
##  8 Driving (free time)            2
##  9 Driving (home)                 8
## 10 Driving (pick up kids)        12
## # … with 35 more rows
#Wednesday
groupbywedAct <- wednesday %>%
  dplyr::group_by(Activity) %>%
  dplyr::summarize(count = n())
groupbywedAct
## # A tibble: 36 x 2
##    Activity                 count
##    <chr>                    <int>
##  1 Babysitting                  5
##  2 Breakfast                    8
##  3 Church                       1
##  4 Cooking                     26
##  5 Dinner                      17
##  6 Driving (gym)                4
##  7 Driving (home)               8
##  8 Driving (order delivery)     9
##  9 Driving (work)              13
## 10 Exercise (Jog, walk)         3
## # … with 26 more rows
#Thursday
groupbythuAct <- thursday %>%
  dplyr::group_by(Activity) %>%
  dplyr::summarize(count = n())
groupbythuAct
## # A tibble: 40 x 2
##    Activity                   count
##    <chr>                      <int>
##  1 Breakfast                      4
##  2 Church (social activities)     7
##  3 Cooking                        6
##  4 Cooking (business)             3
##  5 Cooking (lunch)                1
##  6 Dinner                         8
##  7 Driving (church)               1
##  8 Driving (drop kids)            1
##  9 Driving (gym)                  2
## 10 Driving (home)                 4
## # … with 30 more rows
#Friday
groupbyfriAct <- friday %>%
  dplyr::group_by(Activity) %>%
  dplyr::summarize(count = n())
groupbyfriAct
## # A tibble: 35 x 2
##    Activity                 count
##    <chr>                    <int>
##  1 Breakfast                    5
##  2 Church                       1
##  3 Cooking                     16
##  4 Dinner                      15
##  5 Driving (church)             1
##  6 Driving (drop relatives)     2
##  7 Driving (farm)               4
##  8 Driving (gym)                2
##  9 Driving (home)               8
## 10 Driving (Kava)               1
## # … with 25 more rows
#Weekdays
groupbyWkdAct <- newdata %>%
  dplyr::group_by(Activity) %>%
  dplyr::summarize(count = n())
groupbyWkdAct
## # A tibble: 70 x 2
##    Activity                   count
##    <chr>                      <int>
##  1 Babysitting                    5
##  2 Breakfast                     38
##  3 Charging mobile devices        1
##  4 Church                         8
##  5 Church (choir practice)        2
##  6 Church (social activities)    14
##  7 Cooking                      102
##  8 Cooking (baby)                 1
##  9 Cooking (business)             6
## 10 Cooking (lunch)                2
## # … with 60 more rows

Im am trying to remove sleeping, rest, going to work from the data so that i can only focus on the rest of the acitivities.

The issue i am facing as the time is not sorted in accending order. Can you help with the coding

yep - see what I did :-)

tableAll <- monday %>%
  #select(Time, Activity) %>% 
  select(fixedHMS, Activity) %>% # use the new time variable
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  #group_by(Time) %>% 
  group_by(fixedHMS) %>% 
  tally

kableExtra::kable(tableAll, caption = "Monday test (no sleep/rest/work)") %>%
  kable_styling()
Table 3.1: Monday test (no sleep/rest/work)
fixedHMS n
00:00:00 4
00:30:00 2
04:30:00 1
05:00:00 5
05:30:00 7
06:00:00 13
06:30:00 19
07:00:00 30
07:30:00 29
08:00:00 28
08:30:00 8
09:00:00 2
09:30:00 1
10:00:00 1
15:00:00 1
15:30:00 2
16:00:00 3
16:30:00 7
17:00:00 26
17:30:00 24
18:00:00 25
18:30:00 26
19:00:00 30
19:30:00 30
20:00:00 30
20:30:00 30
21:00:00 29
21:30:00 27
22:00:00 22
22:30:00 19
23:00:00 12
23:30:00 8
# plot
ggplot2::ggplot(tableAll, aes(x = fixedHMS, y = n)) +
  geom_col()

3.2 Cooking

Here im am trying to look at anything related to preparing and eating a meal.

# creating dataframe for all cooking
#Monday
tableCooking <- monday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Cooking", 
                         "Cooking (business)", 
                         "Cooking (baby)",
                         "Cooking (lunch)", 
                         "Food prep (business)", 
                         "Lunch", 
                         "Breakfast", 
                         "Dinner", 
                         "Light meal/snack")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
tableCooking
## # A tibble: 17 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 06:00        3
##  2 06:30        5
##  3 07:00        7
##  4 07:30        6
##  5 08:00        3
##  6 08:30        2
##  7 09:00        1
##  8 17:00        1
##  9 17:30        4
## 10 18:00        8
## 11 18:30        9
## 12 19:00       10
## 13 19:30       13
## 14 20:00        8
## 15 20:30        6
## 16 21:00        2
## 17 21:30        1
MonCook <- ggplot(tableCooking, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="blue", fill="blue") +
  ggtitle("Monday Cooking") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

MonCook

#Tuesday

tableCookingTue <- tuesday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Cooking", 
                         "Cooking (business)", 
                         "Cooking (baby)",
                         "Cooking (lunch)", 
                         "Food prep (business)", 
                         "Lunch", 
                         "Breakfast", 
                         "Dinner", 
                         "Light meal/snack")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
tableCookingTue
## # A tibble: 24 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:00        1
##  2 05:30        1
##  3 06:00        2
##  4 06:30        2
##  5 07:00        1
##  6 07:30        1
##  7 08:00        1
##  8 09:00        1
##  9 12:30        1
## 10 13:00        1
## # … with 14 more rows
TueCook <- ggplot(tableCookingTue, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="blue", fill="blue") +
  ggtitle("Tuesday Cooking") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

TueCook

#Wednesday

tableCookingWed <- wednesday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Cooking", 
                         "Cooking (business)", 
                         "Cooking (baby)",
                         "Cooking (lunch)", 
                         "Food prep (business)", 
                         "Lunch", 
                         "Breakfast", 
                         "Dinner", 
                         "Light meal/snack")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
tableCookingWed
## # A tibble: 14 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 06:00        2
##  2 06:30        2
##  3 07:00        5
##  4 07:30        6
##  5 08:00        1
##  6 17:30        1
##  7 18:00        3
##  8 18:30        4
##  9 19:00        8
## 10 19:30        8
## 11 20:00        4
## 12 20:30        4
## 13 21:00        2
## 14 21:30        1
WedCook <- ggplot(tableCookingWed, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="blue", fill="blue") +
  ggtitle("Wednesday Cooking") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

WedCook

#Thursday

tableCookingThu <- thursday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Cooking", 
                         "Cooking (business)", 
                         "Cooking (baby)",
                         "Cooking (lunch)", 
                         "Food prep (business)", 
                         "Lunch", 
                         "Breakfast", 
                         "Dinner", 
                         "Light meal/snack")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
tableCookingThu
## # A tibble: 20 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 06:30        1
##  2 07:30        1
##  3 08:00        2
##  4 08:30        1
##  5 09:00        1
##  6 09:30        1
##  7 10:00        1
##  8 14:30        1
##  9 17:30        2
## 10 18:00        1
## 11 18:30        3
## 12 19:00        2
## 13 19:30        1
## 14 20:00        2
## 15 20:30        1
## 16 21:00        1
## 17 21:30        1
## 18 22:00        1
## 19 22:30        1
## 20 23:00        1
ThuCook <- ggplot(tableCookingThu, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="blue", fill="blue") +
  ggtitle("Thursday Cooking") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

ThuCook

#Friday


tableCookingFri <- friday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Cooking", 
                         "Cooking (business)", 
                         "Cooking (baby)",
                         "Cooking (lunch)", 
                         "Food prep (business)", 
                         "Lunch", 
                         "Breakfast", 
                         "Dinner", 
                         "Light meal/snack")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
tableCookingFri
## # A tibble: 20 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 07:00        2
##  2 07:30        1
##  3 09:00        1
##  4 10:00        1
##  5 14:00        1
##  6 14:30        1
##  7 15:00        1
##  8 15:30        1
##  9 16:00        1
## 10 16:30        1
## 11 17:00        1
## 12 17:30        4
## 13 18:00        3
## 14 18:30        5
## 15 19:00        4
## 16 19:30        3
## 17 20:00        2
## 18 20:30        1
## 19 22:00        1
## 20 22:30        1
FriCook <- ggplot(tableCookingFri, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="blue", fill="blue") +
  ggtitle("Friday Cooking") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

FriCook

#Weekdays

tableCookingWkd <- newdata %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Cooking", 
                         "Cooking (business)", 
                         "Cooking (baby)",
                         "Cooking (lunch)", 
                         "Food prep (business)", 
                         "Lunch", 
                         "Breakfast", 
                         "Dinner", 
                         "Light meal/snack")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
tableCookingWkd
## # A tibble: 33 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:00        1
##  2 05:30        1
##  3 06:00        7
##  4 06:30       10
##  5 07:00       15
##  6 07:30       15
##  7 08:00        7
##  8 08:30        3
##  9 09:00        4
## 10 09:30        1
## # … with 23 more rows
WkdCook <- ggplot(tableCookingWkd, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="blue", fill="blue") +
  ggtitle("Weekdays Cooking") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

WkdCook

3.3 Weekdays Tidy up

similar to the above but for tidy up/cleaning up

# creating dataframe for all cleaning up

#Monday
mondayTidyup <- monday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Tidy up", 
                         "Laundry", 
                         "Showering", 
                         "Showering (kids)", 
                         "Gardening", 
                         "Getting dressed", 
                         "Getting dressed (kids)",
                         "Prepare kids bag for school",
                         "Turning off applicances/Lights", 
                         "Turning on appliances/lights", 
                         "Ironing", 
                         "Feeding animals")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
mondayTidyup
## # A tibble: 21 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:30        1
##  2 06:00        3
##  3 06:30        5
##  4 07:00        7
##  5 07:30       17
##  6 08:00        7
##  7 09:00        1
##  8 09:30        1
##  9 17:00        1
## 10 17:30        2
## # … with 11 more rows
MondayTidy <- ggplot(mondayTidyup, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="red", fill="red") +
  ggtitle("Monday Tidy up") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

MondayTidy

#Tuesday
tuesdayTidyup <- tuesday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Tidy up", 
                         "Laundry", 
                         "Showering", 
                         "Showering (kids)", 
                         "Gardening", 
                         "Getting dressed", 
                         "Getting dressed (kids)",
                         "Prepare kids bag for school",
                         "Turning off applicances/Lights", 
                         "Turning on appliances/lights", 
                         "Ironing", 
                         "Feeding animals")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
tuesdayTidyup
## # A tibble: 24 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:30        1
##  2 06:00        1
##  3 06:30        5
##  4 07:00        7
##  5 07:30       10
##  6 08:00        5
##  7 08:30        1
##  8 09:30        1
##  9 10:00        1
## 10 11:00        1
## # … with 14 more rows
TuesdayTidy <- ggplot(tuesdayTidyup, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="red", fill="red") +
  ggtitle("Tuesday Tidy up") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

TuesdayTidy

#Wednesday
wednesdayTidyup <- wednesday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Tidy up", 
                         "Laundry", 
                         "Showering", 
                         "Showering (kids)", 
                         "Gardening", 
                         "Getting dressed", 
                         "Getting dressed (kids)",
                         "Prepare kids bag for school",
                         "Turning off applicances/Lights", 
                         "Turning on appliances/lights", 
                         "Ironing", 
                         "Feeding animals")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
wednesdayTidyup
## # A tibble: 27 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:30        1
##  2 05:30        1
##  3 06:00        1
##  4 06:30        3
##  5 07:00        3
##  6 07:30        6
##  7 08:00        6
##  8 08:30        1
##  9 09:00        1
## 10 14:00        1
## # … with 17 more rows
WednesdayTidy <- ggplot(wednesdayTidyup, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="red", fill="red") +
  ggtitle("Wednesday Tidy up") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

WednesdayTidy

#Thursday
thursdayTidyup <- thursday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Tidy up", 
                         "Laundry", 
                         "Showering", 
                         "Showering (kids)", 
                         "Gardening", 
                         "Getting dressed", 
                         "Getting dressed (kids)",
                         "Prepare kids bag for school",
                         "Turning off applicances/Lights", 
                         "Turning on appliances/lights", 
                         "Ironing", 
                         "Feeding animals")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
thursdayTidyup
## # A tibble: 18 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:30        1
##  2 06:30        1
##  3 07:00        4
##  4 07:30        5
##  5 08:00        1
##  6 13:00        1
##  7 13:30        1
##  8 14:00        1
##  9 17:30        1
## 10 18:00        1
## 11 19:00        2
## 12 19:30        3
## 13 20:00        2
## 14 21:00        2
## 15 21:30        2
## 16 22:00        1
## 17 22:30        1
## 18 23:00        1
ThursdayTidy <- ggplot(thursdayTidyup, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="red", fill="red") +
  ggtitle("Thursday Tidy up") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

ThursdayTidy

#Friday
fridayTidyup <- friday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Tidy up", 
                         "Laundry", 
                         "Showering", 
                         "Showering (kids)", 
                         "Gardening", 
                         "Getting dressed", 
                         "Getting dressed (kids)",
                         "Prepare kids bag for school",
                         "Turning off applicances/Lights", 
                         "Turning on appliances/lights", 
                         "Ironing", 
                         "Feeding animals")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
fridayTidyup
## # A tibble: 19 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:30        1
##  2 06:30        3
##  3 07:00        4
##  4 07:30        6
##  5 08:00        6
##  6 08:30        2
##  7 09:30        2
##  8 12:00        1
##  9 12:30        1
## 10 13:00        1
## 11 13:30        1
## 12 17:00        1
## 13 17:30        4
## 14 18:00        3
## 15 18:30        2
## 16 19:30        2
## 17 21:30        1
## 18 22:00        1
## 19 22:30        2
FridayTidy <- ggplot(fridayTidyup, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="red", fill="red") +
  ggtitle("Friday Tidy up") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

FridayTidy

#Weekdays
weekdaysTidyup <- newdata %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Tidy up", 
                         "Laundry", 
                         "Showering", 
                         "Showering (kids)", 
                         "Gardening", 
                         "Getting dressed", 
                         "Getting dressed (kids)",
                         "Prepare kids bag for school",
                         "Turning off applicances/Lights", 
                         "Turning on appliances/lights", 
                         "Ironing", 
                         "Feeding animals")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
weekdaysTidyup
## # A tibble: 36 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:30        3
##  2 05:30        3
##  3 06:00        5
##  4 06:30       17
##  5 07:00       25
##  6 07:30       44
##  7 08:00       25
##  8 08:30        4
##  9 09:00        2
## 10 09:30        4
## # … with 26 more rows
WeekdaysTidy <- ggplot(weekdaysTidyup, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="red", fill="red") +
  ggtitle("Weekdays Tidy up") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

WeekdaysTidy

3.4 Weekday Leisure

similar to the above but for leisure

# creating dataframe for all leisure

#Monday
mondayleisure <- monday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Babysitting", 
                         "Charging mobile devices", 
                         "Family devotion",
                         "Exercise (Jog, walk)",
                         "Family time (chatting, games etc)",
                         "Homework (kids)",
                         "Kids bedtime",
                         "Listen to music/radio",
                         "Mobile devices (movies)",
                         "Mobile devices (games)",
                         "Mobile devices (work)",
                         "Mobile devices (browsing, social media)",
                         "Scripture study",
                         "Studying", 
                         "Reading",
                         "Watching movies (TV)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
mondayleisure
## # A tibble: 18 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:00        1
##  2 00:30        1
##  3 05:30        2
##  4 06:30        1
##  5 07:00        1
##  6 17:30        1
##  7 18:00        2
##  8 18:30        6
##  9 19:00       10
## 10 19:30       10
## 11 20:00       15
## 12 20:30       15
## 13 21:00       18
## 14 21:30       19
## 15 22:00       15
## 16 22:30       12
## 17 23:00        8
## 18 23:30        4
Mondayleisure <- ggplot(mondayleisure, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="violet", fill="violet") +
  ggtitle("Monday Leisure") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

Mondayleisure

#Tuesday
tuesdayleisure <- tuesday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Babysitting", 
                         "Charging mobile devices", 
                         "Family devotion",
                         "Exercise (Jog, walk)",
                         "Family time (chatting, games etc)",
                         "Homework (kids)",
                         "Kids bedtime",
                         "Listen to music/radio",
                         "Mobile devices (movies)",
                         "Mobile devices (games)",
                         "Mobile devices (work)",
                         "Mobile devices (browsing, social media)",
                         "Scripture study",
                         "Studying", 
                         "Reading",
                         "Watching movies (TV)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
tuesdayleisure
## # A tibble: 18 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:00        5
##  2 00:30        4
##  3 03:00        1
##  4 08:00        1
##  5 15:30        1
##  6 17:30        3
##  7 18:00        2
##  8 18:30        5
##  9 19:00        8
## 10 19:30        9
## 11 20:00        8
## 12 20:30        9
## 13 21:00       10
## 14 21:30       12
## 15 22:00       13
## 16 22:30       12
## 17 23:00        8
## 18 23:30        5
Tuesdayleisure <- ggplot(tuesdayleisure, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="violet", fill="violet") +
  ggtitle("Tuesday Leisure") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

Tuesdayleisure

#Wednesday
wednesdayleisure <- wednesday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Babysitting", 
                         "Charging mobile devices", 
                         "Family devotion",
                         "Exercise (Jog, walk)",
                         "Family time (chatting, games etc)",
                         "Homework (kids)",
                         "Kids bedtime",
                         "Listen to music/radio",
                         "Mobile devices (movies)",
                         "Mobile devices (games)",
                         "Mobile devices (work)",
                         "Mobile devices (browsing, social media)",
                         "Scripture study",
                         "Studying", 
                         "Reading",
                         "Watching movies (TV)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
wednesdayleisure
## # A tibble: 19 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:00        1
##  2 05:30        1
##  3 06:00        1
##  4 07:00        1
##  5 16:30        1
##  6 17:00        1
##  7 17:30        4
##  8 18:00        4
##  9 18:30        2
## 10 19:00        4
## 11 19:30        3
## 12 20:00        6
## 13 20:30        6
## 14 21:00        8
## 15 21:30        8
## 16 22:00        9
## 17 22:30        8
## 18 23:00        4
## 19 23:30        2
Wednesdayleisure <- ggplot(wednesdayleisure, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="violet", fill="violet") +
  ggtitle("Wednesday Leisure") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

Wednesdayleisure

#Thursday
thursdayleisure <- thursday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Babysitting", 
                         "Charging mobile devices", 
                         "Family devotion",
                         "Exercise (Jog, walk)",
                         "Family time (chatting, games etc)",
                         "Homework (kids)",
                         "Kids bedtime",
                         "Listen to music/radio",
                         "Mobile devices (movies)",
                         "Mobile devices (games)",
                         "Mobile devices (work)",
                         "Mobile devices (browsing, social media)",
                         "Scripture study",
                         "Studying", 
                         "Reading",
                         "Watching movies (TV)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
thursdayleisure
## # A tibble: 15 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 04:30        1
##  2 05:00        1
##  3 05:30        1
##  4 06:00        2
##  5 06:30        2
##  6 19:00        1
##  7 19:30        1
##  8 20:00        2
##  9 20:30        4
## 10 21:00        3
## 11 21:30        2
## 12 22:00        3
## 13 22:30        3
## 14 23:00        4
## 15 23:30        2
Thursdayleisure <- ggplot(thursdayleisure, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="violet", fill="violet") +
  ggtitle("Thursday Leisure") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

Thursdayleisure

#Friday
fridayleisure <- friday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Babysitting", 
                         "Charging mobile devices", 
                         "Family devotion",
                         "Exercise (Jog, walk)",
                         "Family time (chatting, games etc)",
                         "Homework (kids)",
                         "Kids bedtime",
                         "Listen to music/radio",
                         "Mobile devices (movies)",
                         "Mobile devices (games)",
                         "Mobile devices (work)",
                         "Mobile devices (browsing, social media)",
                         "Scripture study",
                         "Studying", 
                         "Reading",
                         "Watching movies (TV)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
fridayleisure
## # A tibble: 36 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:00        4
##  2 00:30        2
##  3 01:00        1
##  4 01:30        1
##  5 02:00        1
##  6 02:30        1
##  7 05:30        1
##  8 06:00        1
##  9 06:30        1
## 10 10:30        1
## # … with 26 more rows
Fridayleisure <- ggplot(fridayleisure, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="violet", fill="violet") +
  ggtitle("Friday Leisure") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

Fridayleisure

#Weekdays
weekdaysleisure <- newdata %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Babysitting", 
                         "Charging mobile devices", 
                         "Family devotion",
                         "Exercise (Jog, walk)",
                         "Family time (chatting, games etc)",
                         "Homework (kids)",
                         "Kids bedtime",
                         "Listen to music/radio",
                         "Mobile devices (movies)",
                         "Mobile devices (games)",
                         "Mobile devices (work)",
                         "Mobile devices (browsing, social media)",
                         "Scripture study",
                         "Studying", 
                         "Reading",
                         "Watching movies (TV)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
weekdaysleisure
## # A tibble: 41 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:00       11
##  2 00:30        7
##  3 01:00        1
##  4 01:30        1
##  5 02:00        1
##  6 02:30        1
##  7 03:00        1
##  8 04:30        1
##  9 05:00        1
## 10 05:30        5
## # … with 31 more rows
Weekdayleisure <- ggplot(weekdaysleisure, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="violet", fill="violet") +
  ggtitle("Weekdays Leisure") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

Weekdayleisure

3.5 Weekdays Away from home

similar to the above but for away from home

# creating dataframe for Away from Home

#Monday
mondayAway <- monday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity %in% c("Farm", 
                         "Relatives", 
                         "Work", 
                         "Kava", 
                         "Church", 
                         "Church (social activities)", 
                         "Church (choir practice)", 
                         "Exercise (Jog, walk)", 
                         "Gym",
                         "Sports",
                         "School", 
                         "Going out"))%>% 
  group_by(fixedHMS) %>% 
  tally
  
  
mondayAway
## # A tibble: 31 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:30        2
##  2 06:00        2
##  3 06:30        3
##  4 07:00        1
##  5 07:30        2
##  6 08:00        4
##  7 08:30       24
##  8 09:00       30
##  9 09:30       31
## 10 10:00       31
## # … with 21 more rows
MondayAwayHome <- ggplot(mondayAway, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="orange", fill="orange") +
  ggtitle("Monday Away From Home") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

MondayAwayHome

#Tuesday
tuesdayAway <- tuesday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity %in% c("Farm", 
                         "Relatives", 
                         "Work", 
                         "Kava", 
                         "Church", 
                         "Church (social activities)", 
                         "Church (choir practice)", 
                         "Exercise (Jog, walk)", 
                         "Gym",
                         "Sports",
                         "School", 
                         "Going out"))%>% 
  group_by(fixedHMS) %>% 
  tally
  
  
tuesdayAway
## # A tibble: 40 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:00        1
##  2 00:30        1
##  3 01:00        1
##  4 01:30        1
##  5 02:00        1
##  6 02:30        1
##  7 07:00        1
##  8 07:30        1
##  9 08:00        3
## 10 08:30       12
## # … with 30 more rows
TuesdayAwayHome <- ggplot(tuesdayAway, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="orange", fill="orange") +
  ggtitle("Tuesday Away From Home") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

TuesdayAwayHome

#Wednesday
wednesdayAway <- wednesday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity %in% c("Farm", 
                         "Relatives", 
                         "Work", 
                         "Kava", 
                         "Church", 
                         "Church (social activities)", 
                         "Church (choir practice)", 
                         "Exercise (Jog, walk)", 
                         "Gym",
                         "Sports",
                         "School", 
                         "Going out"))%>% 
  group_by(fixedHMS) %>% 
  tally
  
  
wednesdayAway
## # A tibble: 31 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:30        2
##  2 06:00        2
##  3 06:30        1
##  4 07:00        1
##  5 08:00        1
##  6 08:30        9
##  7 09:00       14
##  8 09:30       14
##  9 10:00       14
## 10 10:30       14
## # … with 21 more rows
WednesdayAwayHome <- ggplot(wednesdayAway, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="orange", fill="orange") +
  ggtitle("Wednesday Away From Home") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

WednesdayAwayHome

#Thursday
thursdayAway <- thursday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity %in% c("Farm", 
                         "Relatives", 
                         "Work", 
                         "Kava", 
                         "Church", 
                         "Church (social activities)", 
                         "Church (choir practice)", 
                         "Exercise (Jog, walk)", 
                         "Gym",
                         "Sports",
                         "School", 
                         "Going out"))%>% 
  group_by(fixedHMS) %>% 
  tally
  
  
thursdayAway
## # A tibble: 33 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:30        1
##  2 06:00        1
##  3 06:30        1
##  4 07:30        1
##  5 08:00        1
##  6 08:30        6
##  7 09:00        7
##  8 09:30        7
##  9 10:00        7
## 10 10:30        7
## # … with 23 more rows
ThursdayAwayHome <- ggplot(thursdayAway, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="orange", fill="orange") +
  ggtitle("Monday Away From Home") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

ThursdayAwayHome

#Friday
fridayAway <- friday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity %in% c("Farm", 
                         "Relatives", 
                         "Work", 
                         "Kava", 
                         "Church", 
                         "Church (social activities)", 
                         "Church (choir practice)", 
                         "Exercise (Jog, walk)", 
                         "Gym",
                         "Sports",
                         "School", 
                         "Going out"))%>% 
  group_by(fixedHMS) %>% 
  tally
  
  
fridayAway
## # A tibble: 32 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 06:00        1
##  2 07:00        1
##  3 07:30        1
##  4 08:00        3
##  5 08:30        8
##  6 09:00       11
##  7 09:30       13
##  8 10:00       13
##  9 10:30       14
## 10 11:00       14
## # … with 22 more rows
FridayAwayHome <- ggplot(fridayAway, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="orange", fill="orange") +
  ggtitle("Friday Away From Home") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

FridayAwayHome

#Weekday
weekdayAway <- newdata %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>% 
  filter(Activity != "Rest") %>% 
  filter(Activity %in% c("Farm", 
                         "Relatives", 
                         "Work", 
                         "Kava", 
                         "Church", 
                         "Church (social activities)", 
                         "Church (choir practice)", 
                         "Exercise (Jog, walk)", 
                         "Gym",
                         "Sports",
                         "School", 
                         "Going out"))%>% 
  group_by(fixedHMS) %>% 
  tally
  
  
weekdayAway
## # A tibble: 43 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 00:00        1
##  2 00:30        1
##  3 01:00        1
##  4 01:30        1
##  5 02:00        1
##  6 02:30        1
##  7 05:30        5
##  8 06:00        6
##  9 06:30        5
## 10 07:00        4
## # … with 33 more rows
WeekdaysAwayHome <- ggplot(weekdayAway, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="orange", fill="orange") +
  ggtitle("Weekdays Away From Home") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

WeekdaysAwayHome

3.6 Monday Transport

similar to the above but for transportation

BA: table breaks for some reason?

# creating dataframe for transportation

# Monday
mondayTransport <- monday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Driving (church)", 
                         "Driving (drop kids)", 
                         "Driving (drop relatives)",
                         "Driving (farm)", 
                         "Driving (free time)", 
                         "Driving (gym)", 
                         "Driving (home)", 
                         "Driving (Kava)", 
                         "Driving (order delivery)", 
                         "Driving (pick up kids)", 
                         "Driving (visiting relatives)", 
                         "Driving (work)", 
                         "Public transport (home)", 
                         "Public transport (work)", 
                         "Public transport (school)", 
                         "Walking (home)",  
                         "Walking (work)", 
                         "Walking (Kava)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
mondayTransport
## # A tibble: 21 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:00        1
##  2 07:00        2
##  3 07:30        6
##  4 08:00       17
##  5 08:30        6
##  6 10:00        1
##  7 15:00        1
##  8 15:30        2
##  9 16:00        3
## 10 16:30        5
## # … with 11 more rows
#ploting Bar graph

MondayTransport <- ggplot(mondayTransport, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="purple", fill="purple") +
  ggtitle("Monday Travelling") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

MondayTransport

# Tuesday
tuesdayTransport <- tuesday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Driving (church)", 
                         "Driving (drop kids)", 
                         "Driving (drop relatives)",
                         "Driving (farm)", 
                         "Driving (free time)", 
                         "Driving (gym)", 
                         "Driving (home)", 
                         "Driving (Kava)", 
                         "Driving (order delivery)", 
                         "Driving (pick up kids)", 
                         "Driving (visiting relatives)", 
                         "Driving (work)", 
                         "Public transport (home)", 
                         "Public transport (work)", 
                         "Public transport (school)", 
                         "Walking (home)",  
                         "Walking (work)", 
                         "Walking (Kava)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
tuesdayTransport
## # A tibble: 21 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 06:30        1
##  2 07:00        1
##  3 07:30        3
##  4 08:00        9
##  5 08:30        5
##  6 09:00        3
##  7 09:30        3
##  8 10:00        2
##  9 10:30        1
## 10 11:00        1
## # … with 11 more rows
#ploting Bar graph

TuesdayTransport <- ggplot(tuesdayTransport, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="purple", fill="purple") +
  ggtitle("Tuesday Travelling") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

TuesdayTransport

# Wednesday
wednesdayTransport <- wednesday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Driving (church)", 
                         "Driving (drop kids)", 
                         "Driving (drop relatives)",
                         "Driving (farm)", 
                         "Driving (free time)", 
                         "Driving (gym)", 
                         "Driving (home)", 
                         "Driving (Kava)", 
                         "Driving (order delivery)", 
                         "Driving (pick up kids)", 
                         "Driving (visiting relatives)", 
                         "Driving (work)", 
                         "Public transport (home)", 
                         "Public transport (work)", 
                         "Public transport (school)", 
                         "Walking (home)",  
                         "Walking (work)", 
                         "Walking (Kava)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
wednesdayTransport
## # A tibble: 19 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:00        1
##  2 05:30        1
##  3 07:30        1
##  4 08:00        7
##  5 08:30        5
##  6 09:30        1
##  7 10:00        1
##  8 10:30        1
##  9 11:00        1
## 10 11:30        1
## 11 12:00        1
## 12 12:30        1
## 13 13:00        1
## 14 13:30        1
## 15 16:30        2
## 16 17:00        6
## 17 17:30        2
## 18 18:30        1
## 19 20:00        1
#ploting Bar graph

WednesdayTransport <- ggplot(wednesdayTransport, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="purple", fill="purple") +
  ggtitle("Wednesday Travelling") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

WednesdayTransport

# Thursday
thursdayTransport <- thursday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Driving (church)", 
                         "Driving (drop kids)", 
                         "Driving (drop relatives)",
                         "Driving (farm)", 
                         "Driving (free time)", 
                         "Driving (gym)", 
                         "Driving (home)", 
                         "Driving (Kava)", 
                         "Driving (order delivery)", 
                         "Driving (pick up kids)", 
                         "Driving (visiting relatives)", 
                         "Driving (work)", 
                         "Public transport (home)", 
                         "Public transport (work)", 
                         "Public transport (school)", 
                         "Walking (home)",  
                         "Walking (work)", 
                         "Walking (Kava)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
thursdayTransport
## # A tibble: 13 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 07:00        1
##  2 07:30        1
##  3 08:00        4
##  4 08:30        1
##  5 10:30        1
##  6 11:00        1
##  7 11:30        1
##  8 12:00        1
##  9 12:30        1
## 10 16:30        2
## 11 17:00        2
## 12 17:30        2
## 13 18:00        1
#ploting Bar graph

ThursdayTransport <- ggplot(thursdayTransport, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="purple", fill="purple") +
  ggtitle("Thursday Travelling") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

ThursdayTransport

# Friday
fridayTransport <- friday %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Driving (church)", 
                         "Driving (drop kids)", 
                         "Driving (drop relatives)",
                         "Driving (farm)", 
                         "Driving (free time)", 
                         "Driving (gym)", 
                         "Driving (home)", 
                         "Driving (Kava)", 
                         "Driving (order delivery)", 
                         "Driving (pick up kids)", 
                         "Driving (visiting relatives)", 
                         "Driving (work)", 
                         "Public transport (home)", 
                         "Public transport (work)", 
                         "Public transport (school)", 
                         "Walking (home)",  
                         "Walking (work)", 
                         "Walking (Kava)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
fridayTransport
## # A tibble: 14 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:30        1
##  2 06:30        1
##  3 07:30        2
##  4 08:00        3
##  5 08:30        3
##  6 09:00        1
##  7 10:00        1
##  8 16:30        2
##  9 17:00        4
## 10 17:30        2
## 11 18:00        1
## 12 19:00        4
## 13 19:30        1
## 14 21:30        1
#ploting Bar graph

FridayTransport <- ggplot(fridayTransport, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="purple", fill="purple") +
  ggtitle("Friday Travelling") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

FridayTransport

# Weekday
weekdayTransport <- newdata %>%
  select(fixedHMS, Activity) %>% 
  filter(Activity != "Sleeping") %>%
  filter(Activity != "Rest") %>%
  filter(Activity != "Work") %>%
  filter(Activity %in% c("Driving (church)", 
                         "Driving (drop kids)", 
                         "Driving (drop relatives)",
                         "Driving (farm)", 
                         "Driving (free time)", 
                         "Driving (gym)", 
                         "Driving (home)", 
                         "Driving (Kava)", 
                         "Driving (order delivery)", 
                         "Driving (pick up kids)", 
                         "Driving (visiting relatives)", 
                         "Driving (work)", 
                         "Public transport (home)", 
                         "Public transport (work)", 
                         "Public transport (school)", 
                         "Walking (home)",  
                         "Walking (work)", 
                         "Walking (Kava)")) %>% 
  group_by(fixedHMS) %>% 
  tally
  
  
weekdayTransport
## # A tibble: 33 x 2
##    fixedHMS     n
##    <time>   <int>
##  1 05:00        2
##  2 05:30        2
##  3 06:30        2
##  4 07:00        4
##  5 07:30       13
##  6 08:00       40
##  7 08:30       20
##  8 09:00        4
##  9 09:30        4
## 10 10:00        5
## # … with 23 more rows
#ploting Bar graph

WeekdaysTransport <- ggplot(weekdayTransport, aes(x = fixedHMS, y = n)) + geom_bar(stat = "identity", position = "stack", color="purple", fill="purple") +
  ggtitle("Weekdays Travelling") +
  xlab("Time ") +
  ylab("n") + theme(plot.title = element_text(color="Black", size=11, face="bold.italic", hjust=0.5,lineheight=0.8),
        axis.title.x = element_text(color="black", size=10, face="bold"),
        axis.title.y = element_text(color="black", size=10, face="bold"),
        panel.background=element_rect(fill = "white"),
        panel.grid.minor = element_blank(),
        panel.grid.major = element_blank(), 
        axis.line = element_line(colour = "black", size = 1) + 
        scale_x_date(labels = date_format("%I:%M %p"))
)

WeekdaysTransport

3.7 Monday Multiple plots

I wanted to put all the graphs in one page

#graphs in one page

library(grid)
library(gridExtra)
## 
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
## 
##     combine
library(gridBase)

BA: I would do this a different way by re-coding and putting all the plots in one plot:

# I would use data.table for this, not because it is the best way but because I know how to use it!
library(data.table)
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:lubridate':
## 
##     hour, isoweek, mday, minute, month, quarter, second, wday,
##     week, yday, year
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## The following object is masked from 'package:purrr':
## 
##     transpose
mondayDT <- data.table::as.data.table(monday)
mondayDT[, ba_act := ifelse(Activity %in% c("Cooking", 
                         "Cooking (business)", 
                         "Cooking (baby)",
                         "Cooking (lunch)", 
                         "Food prep (business)", 
                         "Lunch", 
                         "Breakfast", 
                         "Dinner", 
                         "Light meal/snack"), 
                            "Cooking", # <- new code
                            NA)
         ]

mondayDT[, ba_act := ifelse(Activity %in% c("Tidy up", 
                         "Laundry", 
                         "Showering", 
                         "Showering (kids)", 
                         "Gardening", 
                         "Getting dressed", 
                         "Getting dressed (kids)",
                         "Prepare kids bag for school",
                         "Turning off applicances/Lights", 
                         "Turning on appliances/lights", 
                         "Ironing", 
                         "Feeding animals"),
                            "Tidy up", 
                            ba_act)
         ]

mondayDT[, ba_act := ifelse(Activity %in% c("Babysitting", 
                         "Charging mobile devices", 
                         "Family devotion",
                         "Exercise (Jog, walk)",
                         "Family time (chatting, games etc)",
                         "Homework (kids)",
                         "Kids bedtime",
                         "Listen to music/radio",
                         "Mobile devices (movies)",
                         "Mobile devices (games)",
                         "Mobile devices (work)",
                         "Mobile devices (browsing, social media)",
                         "Scripture study",
                         "Studying", 
                         "Reading",
                         "Watching movies (TV)"), 
                            "Leisure", 
                            ba_act)
         ]

mondayDT[, ba_act := ifelse(Activity %in% c("Farm", 
                         "Relatives", 
                         "Work", 
                         "Kava", 
                         "Church", 
                         "Church (social activities)", 
                         "Church (choir practice)", 
                         "Exercise (Jog, walk)", 
                         "Gym",
                         "Sports",
                         "School", 
                         "Going out"), 
                            "Away", 
                            ba_act)
         ]

mondayDT[, ba_act := ifelse(Activity %in% c("Driving (church)", 
                         "Driving (drop kids)", 
                         "Driving (drop relatives)",
                         "Driving (farm)", 
                         "Driving (free time)", 
                         "Driving (gym)", 
                         "Driving (home)", 
                         "Driving (Kava)", 
                         "Driving (order delivery)", 
                         "Driving (pick up kids)", 
                         "Driving (visiting relatives)", 
                         "Driving (work)", 
                         "Public transport (home)", 
                         "Public transport (work)", 
                         "Public transport (school)", 
                         "Walking (home)",  
                         "Walking (work)", 
                         "Walking (Kava)"), 
                            "Transport", 
                            ba_act)
         ]

t <- table(mondayDT$Activity, mondayDT$ba_act, useNA = "always")

kableExtra::kable(t, caption = "Test activity coding") %>%
  kable_styling()
Table 3.2: Test activity coding
Away Cooking Leisure Tidy up Transport NA
Breakfast 0 16 0 0 0 0
Charging mobile devices 0 0 1 0 0 0
Church 6 0 0 0 0 0
Church (social activities) 2 0 0 0 0 0
Cooking 0 31 0 0 0 0
Cooking (baby) 0 1 0 0 0 0
Cooking (business) 0 3 0 0 0 0
Cooking (lunch) 0 1 0 0 0 0
Dinner 0 36 0 0 0 0
Driving (church) 0 0 0 0 1 0
Driving (drop kids) 0 0 0 0 2 0
Driving (drop relatives) 0 0 0 0 1 0
Driving (farm) 0 0 0 0 1 0
Driving (gym) 0 0 0 0 4 0
Driving (home) 0 0 0 0 23 0
Driving (pick up kids) 0 0 0 0 9 0
Driving (visiting relatives) 0 0 0 0 10 0
Driving (work) 0 0 0 0 21 0
Exercise (Jog, walk) 4 0 0 0 0 0
Family devotion 0 0 12 0 0 0
Family time (chatting, games etc) 0 0 4 0 0 0
Farm 2 0 0 0 0 0
Feeding animals 0 0 0 3 0 0
Getting dressed 0 0 0 17 0 0
Getting dressed (kids) 0 0 0 5 0 0
Gym 14 0 0 0 0 0
Home 0 0 0 0 0 24
Homework (kids) 0 0 23 0 0 0
Ironing 0 0 0 7 0 0
Kids bedtime 0 0 6 0 0 0
Laundry 0 0 0 2 0 0
Light meal/snack 0 1 0 0 0 0
Listen to music/radio 0 0 2 0 0 0
Mobile device (movies) 0 0 0 0 0 26
Mobile devices (browsing, social media) 0 0 18 0 0 0
Mobile devices (work) 0 0 12 0 0 0
Prepare kids bag for school 0 0 0 1 0 0
Public transport (home) 0 0 0 0 3 0
Public transport (work) 0 0 0 0 2 0
Reading 0 0 10 0 0 0
Rest 0 0 0 0 0 18
Showering 0 0 0 32 0 0
Sleeping 0 0 0 0 0 467
Tidy up 0 0 0 13 0 0
Turning off appliances/Lights 0 0 0 0 0 2
Walking (home) 0 0 0 0 2 0
Walking (work) 0 0 0 0 4 0
Watching movies (TV) 0 0 49 0 0 0
Woke up 0 0 0 0 0 32
Work 550 0 0 0 0 0
NA 0 0 0 0 0 0
# make a summary table for the plot
plotDT <- mondayDT[!is.na(ba_act), # excludes all NAs - see table to check coding 
                   .(count = .N), keyby = .(fixedHMS, ba_act)]

ggplot2::ggplot(plotDT, aes(x = fixedHMS, y = count, fill = ba_act)) +
  geom_col() +
  scale_fill_discrete(name="Activity (filtered)")

4 All weekdays plotted using facets

Figure 4.1 shows counts for all days. We can see a few days are unknown. Also we have higher counts on Mondays.

# use the all days table and the same coding method but across all days

allDaysDT <- data.table::as.data.table(newdata)

allDaysDT[, dayF := factor(Day,
                        levels = c("Monday", "Tuesday", "Wednesday", "Thursday", "Friday") # sets the order for the plot
                        )
       ]

allDaysDT[, ba_act := ifelse(Activity %in% c("Cooking", 
                         "Cooking (business)", 
                         "Cooking (baby)",
                         "Cooking (lunch)", 
                         "Food prep (business)", 
                         "Lunch", 
                         "Breakfast", 
                         "Dinner", 
                         "Light meal/snack"), 
                            "Cooking", # <- new code
                            NA)
         ]

allDaysDT[, ba_act := ifelse(Activity %in% c("Tidy up", 
                         "Laundry", 
                         "Showering", 
                         "Showering (kids)", 
                         "Gardening", 
                         "Getting dressed", 
                         "Getting dressed (kids)",
                         "Prepare kids bag for school",
                         "Turning off applicances/Lights", 
                         "Turning on appliances/lights", 
                         "Ironing", 
                         "Feeding animals"),
                            "Tidy up", 
                            ba_act)
         ]

allDaysDT[, ba_act := ifelse(Activity %in% c("Babysitting", 
                         "Charging mobile devices", 
                         "Family devotion",
                         "Exercise (Jog, walk)",
                         "Family time (chatting, games etc)",
                         "Homework (kids)",
                         "Kids bedtime",
                         "Listen to music/radio",
                         "Mobile devices (movies)",
                         "Mobile devices (games)",
                         "Mobile devices (work)",
                         "Mobile devices (browsing, social media)",
                         "Scripture study",
                         "Studying", 
                         "Reading",
                         "Watching movies (TV)"), 
                            "Leisure", 
                            ba_act)
         ]

allDaysDT[, ba_act := ifelse(Activity %in% c("Farm", 
                         "Relatives", 
                         "Work", 
                         "Kava", 
                         "Church", 
                         "Church (social activities)", 
                         "Church (choir practice)", 
                         "Exercise (Jog, walk)", 
                         "Gym",
                         "Sports",
                         "School", 
                         "Going out"), 
                            "Away", 
                            ba_act)
         ]

allDaysDT[, ba_act := ifelse(Activity %in% c("Driving (church)", 
                         "Driving (drop kids)", 
                         "Driving (drop relatives)",
                         "Driving (farm)", 
                         "Driving (free time)", 
                         "Driving (gym)", 
                         "Driving (home)", 
                         "Driving (Kava)", 
                         "Driving (order delivery)", 
                         "Driving (pick up kids)", 
                         "Driving (visiting relatives)", 
                         "Driving (work)", 
                         "Public transport (home)", 
                         "Public transport (work)", 
                         "Public transport (school)", 
                         "Walking (home)",  
                         "Walking (work)", 
                         "Walking (Kava)"), 
                            "Transport", 
                            ba_act)
         ]

# t <- table(allDaysDT$Activity, allDaysDT$ba_act, useNA = "always")
# 
# kableExtra::kable(t, caption = "Test activity coding (all days)") %>%
#   kable_styling()

# make a summary table for the plot
plotDT <- allDaysDT[!is.na(ba_act), # excludes all NAs - see table to check coding 
                   .(count = .N), 
                   keyby = .(fixedHMS, ba_act, dayF)] # use new day factor



ggplot2::ggplot(plotDT, aes(x = fixedHMS, y = count, fill = ba_act)) +
  geom_col() +
  facet_grid(dayF ~ .) +
  scale_fill_discrete(name="Activity (filtered)")
All days

Figure 4.1: All days

t <- with(allDaysDT[!is.na(ba_act)], # select the ones we re-coded only
          table(ba_act, dayF))

kableExtra::kable(t, caption = "Number of recorded coded acts by day (non recoded actas e.g. sleeping ignored)") %>%
  kable_styling()
Table 4.1: Number of recorded coded acts by day (non recoded actas e.g. sleeping ignored)
Monday Tuesday Wednesday Thursday Friday
Away 578 315 257 141 253
Cooking 89 56 51 26 36
Leisure 137 114 71 29 89
Tidy up 80 55 57 31 44
Transport 83 57 36 19 27
t <- allDaysDT[, .(nRespondents = uniqueN(`Household ID`)), keyby = .(dayF)]

kableExtra::kable(t, caption = "Number of unique respondents by day (all acts)") %>%
  kable_styling()
Table 4.1: Number of unique respondents by day (all acts)
dayF nRespondents
Monday 32
Tuesday 19
Wednesday 15
Thursday 8
Friday 15

There are a lot of Mondays in this data…

How many are there per village?

dt <- allDaysDT[, .(n = uniqueN(`Household ID`)), 
                   keyby = .(Village)]



kableExtra::kable(dt, caption = "Number of respondents by village")
Table 4.2: Number of respondents by village
Village n
Fanga 2
Fangaloto 5
Fasi 8
Fuaamotu 8
Ha’ateiho 3
Halaleva 1
Halaovave 1
Havelu 6
Hofoa 1
Houma 1
Houmakelikao 2
Kolofo’ou 1
Kolomotu’a 7
Lakepa 2
Lapaha 2
Liahona 5
Longolongo 1
Ma’ufanga 3
Mailetaha 1
Malapo 1
Matahau 1
Mataika 1
Navutoka 1
Ngele’ia 1
Niutoua 1
Nukunuku 1
Pahu 1
Popua 4
Puke 1
Sopu 1
Tatakamotonga 1
Te’ekiu 1
Tofoa 1
Tokomololo 1
Tuatakilangi 2
Umusi 1
Vaini 6
Vaololoa 1
Veitongo 1

Ben, so far with the graphs not convinced its good enough, how can i use “proportion” instead of “count” in the Y axis? Given the uneven distribution of respondents per day

5 Conclusions