# Packages -------------------------

# Dataset manipulation
library(tidyverse)

# Formating output
library(knitr)
library(kableExtra)
library(wkFocus)

# Rmd chunk options
opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)  
opts_chunk$set(comment = NA)  # do not prepend chunk results with a marker
opts_chunk$set(fig.path = "images/")  # dump a copy of the figures here
opts_chunk$set(fig.width = 10)

# Ploting options
plopt <- list("wkf.pl.duration" = as.difftime("00:15:00", format = "%T"))
oplopt <- options(plopt)

## Set local vignette parameter

ds_list_name <- paste0(params$dataset, "_focus")

Dataset 'r ds_list_name'. Initial exploration

## Read dataset from package data into "Global" environment

load(file.path("..", "data", paste0(ds_list_name, ".rda")))

# Flip parameter to a "Global" symbol to be used as a handle on the dataset
#  throughout vignette. Eg, if ds_list_name is "res1A_focus", `ds_list` will
#  point to a copy of the loaded dataset with that name.

ds_list <-  eval(as.symbol(ds_list_name))

## For plotting, stack all codestamps in one data frame
ds_stack <- wkf_stack_cstamps(ds_list)

Specifications for codesets in this dataset

ds_specs <- ds_list %>% {
  tibble(
    codeset  = seq_along(ds_list),
    sid      = map_chr(., c("ds_id", "sid")),
    coder    = map_chr(., c("ds_id", "coder")),
    version  = map_chr(., c("ds_id", "version")),
    source   = map_chr(., "ds_src"), 
    type     = map_chr(., "ds_type"),
    cstamps  = map_int(., ~ nrow(.$data)),
    duration = map(., ~ max(.$data$Out) - min(.$data$In))
  )
}

ds_specs %>% 
  kable(align = "l", caption = paste("Specifications for datasets in", ds_list_name)) %>%
  kable_styling(position = "left") 

Examine data

Quick look for missing data

# Present count of NAs in each variable
ds_list %>% 
  map_dfr(~ summarize(.$data, 
              cstamps = n(), 
              NArounds = sum(is.na(round)), 
              NAgid = sum(is.na(gid)), 
              NAtypes = sum(is.na(type)), 
              NAbins = sum(is.na(bin)), 
              NAIns = sum(is.na(In)), 
              NAOuts = sum(is.na(Out)), 
              NAcodes = sum(is.na(code))), 
          .id = "codeset") %>% 
  kable(caption = paste("Missing values (NA) in ", ds_list_name)) %>%
  kable_styling(position = "left")

### Complete listing of codestamps in dataset wzxhzdk:4

### Counts of codes for each codeset wzxhzdk:5

### Duration scatter plot: Out vs In wzxhzdk:6 ### Summary statistics for code duration wzxhzdk:7

### Codestamps plotted against time in session wzxhzdk:8

zmdg11/wkFocus documentation built on May 26, 2019, 6:33 a.m.