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

View source: R/DataActionsbyID_m0.R

DataActionsbyIDR Documentation

Wide format dataset with the sequence of actions by ID

Description

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

Usage

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

# 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 Oct. 25, 2022, 9:08 a.m.

Related to DataActionsbyID in LOGAN...