Week 1 R basics

1.1 Quarantine log

day1_activity = c("breakfast",
                   "exam prep",
                   "online course",
                   "seminar",
                   "running",
                   "lunch",
                   "check email",
                  "TV series")
day1_is_work = c(FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE)
day1_minutues = c(30,240,120,60,20,45,30)

n = length(day1_activity)
day1_total_hours = sum(day1_minutues)/60
day1_work_hours = sum(day1_minutues[day1_is_work]) / 60

cat("Total time recorded for day 1 : ", day1_total_hours, "hours, over", n, "activities\n")
## Total time recorded for day 1 :  9.083333 hours, over 8 activities
cat("Total time working for day 1 : ", day1_work_hours, "hours \n\n")
## Total time working for day 1 :  7.5 hours

daily_levels = c("connect",
                 "work",
                 "workout",
                 "essential",
                 "fun",
                 "hobby")

## day1_classes = factor(
##  c("essential","work","work","work","workout","essential","connect","fun"),
##  levels = daily_levels
##)

daily_map = c("breakfast" = "essential",
              "exam prep" = "work",
              "online course" = "work",
              "seminar" = "work",
              "running" = "workout",
              "walk" = "workout",
              "lunch" = "essential",
              "check email" = "connect",
              "TV series" = "fun",
              "music" = "hobby",
              "R learning" = "hobby",
              "lab meeting" = "work"
              )

day1_classes = factor(daily_map[day1_activity], levels = daily_levels)

print(day1_classes)
##     breakfast     exam prep online course       seminar       running 
##     essential          work          work          work       workout 
##         lunch   check email     TV series 
##     essential       connect           fun 
## Levels: connect work workout essential fun hobby

day1_dates = rep("04-19-2020",length(day1_activity))
day1_dates = as.Date(day1_dates, format = "%m-%d-%y")