Learn R Programming

LOGAN (version 1.0.1)

DataActionsbyID: 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)

Value

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

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

Examples

Run this code
# 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")

Run the code above in your browser using DataLab