prepare.netfacs: Take data that are not currently in format and turn them into...

View source: R/prepare_netfacs.R

prepare.netfacsR Documentation

Take data that are not currently in format and turn them into the correct format for netfacs function


The netfacs function requires data to be entered with the element data as a matrix of each element by each event, with occurrence marked as 1 and non-occurrence marked as 0.
This is often not the case, so this function transforms data in other routine formats to have the right look.
Specifically, users can define whether they want to enter 'photos', which indicates that all elements in an event are simply strung together in a vector; or they define 'video', in which case it is assumed that each element has a start and an end point in a specified video


  type = c("video", "photo"), = NULL,
  start.time = NULL,
  duration = NULL,
  separator = ",",
  frame.duration = NULL



vector with either one element per index (for videos) or all elements that occurred in the whole event (for photos)


either 'video' or 'photo'. If 'photo', the function separates the string and returns a matrix of the correct dimensions. If 'video', the function creates a matrix using the highest common factor of all 'durations' and for each of those 'frames' assigns whether each element was present or absent

name of the video, so all cases are treated together. For photos, can be entered so that photos can be matched to IDs after


for videos, time when the element is first active


for videos, how long is the element active for


for photos, how are elements separated in the list


for videos, how long is a 'frame' supposed to last? If NULL, frame duration is the shortest 'duration' of any element specified


The assumption for this function is that for photos, elements are stored like this:

For videos, the assumption is that they are stored in a data frame like this:
element = AU1, = 1, start.time = 0.5, duration = 2sec


Function returns a list with element.matrix (the matrix of elements and when they occurred) and (the supporting information, e.g. video names, durations, frames etc)


# for a photo <- c(
au.names <- c("photo1", "photo2", "photo3", "photo4", "photo5", "photo6")
au.prepared <- prepare.netfacs(
  elements =,
  type = "photo", = au.names,
  separator = "/"

# for a video
aus <- c(
  "AU1", "AU5", "AU9",
  "AU1", "AU2",
  "AU1", "AU2", "AU10",
  "AU1", "AU2",
  "AU5", "AU17", "AU18",
  "AU6", "AU12"
video.names <- c(
  rep("video1", 3),
  rep("video2", 2),
  rep("video3", 3),
  rep("video4", 2),
  rep("video5", 3),
  rep("video6", 2)
start.times <- c(
  0.1, 0.2, 0.3,
  0.1, 0.3,
  0.1, 0.4, 0.4,
  0.1, 0.2,
  0.1, 0.5, 0.6,
  0.1, 0.2
durations <- rep(0.3, times = length(start.times))
frame.dur <- 0.05
au.prepared <- prepare.netfacs(
  elements = aus,
  type = "video", = video.names,
  start.time = start.times,
  duration = durations,
  frame.duration = frame.dur

NetFACS documentation built on Dec. 7, 2022, 1:12 a.m.