Pontifications

(Part 1, Part 2, Part 3)

library(tidyverse)
library(lubridate)

# Load data; see https://www.kaggle.com/bls/american-time-use-survey

df.act <- read_csv('~henrik/private/vizyns/data/atus/atusact.csv')
df.sum <- read_csv('~henrik/private/vizyns/data/atus/atussum.csv')


# Get a data frame with activity (trcodep), observation weight (tufnwgtp)
# and interval for doing (start - end)

df.tmp <- df.act %>%
  filter(trtier2p == 1301) %>% # Doing sports/exercise
  
  # start and end are minutes since midnight
  transmute(tucaseid,
            trcodep,
            start = as.numeric(substring(tustarttim, 1, 2)) * 60 + as.numeric(substring(tustarttim, 4, 5)),
            end = as.numeric(substring(tustoptime, 1, 2)) * 60 + as.numeric(substring(tustoptime, 4, 5))) %>%
inner_join(df.sum %>% select(tucaseid, tufnwgtp)) %>%
  • Hmmm I haven’t dug into tidyverse and lubridate, time to dig into these so I can figure out what the lines with %>% mean (other than some sort of data pipe?) and what transmute() does! I guess that will be in part 5!

Leave a comment on github