DataActionsbyID: Wide format dataset with the sequence of actions by ID

Description Usage Arguments Value Examples

Description

This is a function that translates a long to wide format dataset.

Usage

1
DataActionsbyID(data, id.var, event.var, name.var.action)

Arguments

data

A matrix or data.frame where the 'event.type' variable is

id.var

a vector with the individuals identification. It is a quo() type.

event.var

a vector with the cleaned concatenate events. See CleanActions function.

name.var.action

A character string that will name the new variable of events

Value

This function returns a data.frame with the only one entry by individual identification and a new 'action.var' variable.

Examples

1
2
3
4
5
6
7
8
9
# Data preparation
df <- cp025q01
df$id <- paste(df[, 1], df[, 2], df[, 3], sep = "-")
df <- m0$TrimVar(df, c("event", "event_type", "diag_state"))
df <- m0$ConcatActions(df, c(rlang::quo(event), rlang::quo(event_type)))
df <- m0$CleanActions(df, event.type, c("ACER_EVENT_" = ""))

# Function demonstration
m0$DataActionsbyID(df, id, new.event.type, "actions")

LOGAN documentation built on May 6, 2019, 1:02 a.m.