| prepare | R Documentation |
Converts event log data (actor, action, time) into wide sequence format
suitable for build_network. Automatically parses timestamps,
detects sessions from time gaps, and handles tie-breaking.
prepare(
data,
actor,
action,
time = NULL,
order = NULL,
session = NULL,
time_threshold = 900,
custom_format = NULL,
is_unix_time = FALSE,
unix_time_unit = c("seconds", "milliseconds", "microseconds")
)
data |
Data frame with event log columns. |
actor |
Character or character vector. Column name(s) identifying who
performed the action (e.g. |
action |
Character. Column name containing the action/state/code. |
time |
Character or NULL. Column name containing timestamps. Supports ISO8601, Unix timestamps (numeric), and 40+ date/time formats. If NULL, row order defines the sequence. Default: NULL. |
order |
Character or NULL. Column name for tie-breaking when timestamps are identical. If NULL, original row order is used. Default: NULL. |
session |
Character, character vector, or NULL. Column name(s) for
explicit session grouping (e.g. |
time_threshold |
Numeric. Maximum gap in seconds between consecutive
events before a new session starts. Only used when |
custom_format |
Character or NULL. Custom |
is_unix_time |
Logical. If TRUE, treat numeric time values as Unix timestamps. Default: FALSE (auto-detected for numeric columns). |
unix_time_unit |
Character. Unit for Unix timestamps:
|
A list with class "nestimate_data" containing:
Data frame in wide format (one row per session, columns T1, T2, ...).
The processed long-format data with session IDs.
Session-level metadata (session ID, actor).
Parsed time values in wide format (if time provided).
List with total_sessions, total_actions, max_sequence_length, unique_actors, etc.
build_network, prepare_onehot
df <- data.frame(
student = rep(1:3, each = 5),
code = sample(c("read", "write", "test"), 15, replace = TRUE),
timestamp = seq.POSIXt(as.POSIXct("2024-01-01"), by = "min", length.out = 15)
)
prepared <- prepare(df, actor = "student", action = "code",
time = "timestamp")
net <- build_network(prepared$sequence_data, method = "relative")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.