get_var_array: Generate a matrix with various lags from a variable in the...

View source: R/get_var_array.R

get_var_arrayR Documentation

Generate a matrix with various lags from a variable in the dataframe

Description

Generate a matrix with various lags from a variable in the dataframe

Usage

get_var_array(
  data,
  subj_var,
  var,
  time_var,
  lags,
  label_length = 1,
  label_output = FALSE
)

Arguments

data

A data frame, data frame extension (e.g. a tibble).

subj_var

A character string referring to the variable that specifies the "subject" variable.

var

A character string referring to the variable that contains the variable values.

time_var

A character string referring to the variable that contains the time variable values (e.g. visit day, minutes, years).

lags

The length of each sliced sequence.

label_length

How many values after are considered to be the label? Default to 1. If label_length = 1, the label value´ is always the value following the sliced sequence.

label_output

logical. if TRUE a list including the matrix with the sliced sequences and a vector with the label is returned.

Value

If label_output is FALSE, a matrix with the sliced sequences is returned. If label_output is TRUE, a list with the matrix and vector with the labels from the same variable is returned.

Examples

get_var_array(alsfrs_data, "subjid", 
"p2", "visdy", lags = 3, 
label_output = FALSE)

long2lstmarray documentation built on Nov. 28, 2022, 5:22 p.m.