% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/prepare_data.R
\name{prepare}
\alias{prepare}
\title{Prepare Event Log Data for Network Estimation}
\usage{
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")
)
}
\arguments{
\item{data}{Data frame with event log columns.}

\item{actor}{Character or character vector. Column name(s) identifying who
performed the action (e.g. \code{"student"} or
\code{c("student", "group")}). If missing, all data is treated as one
actor.}

\item{action}{Character. Column name containing the action/state/code.}

\item{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.}

\item{order}{Character or NULL. Column name for tie-breaking when
timestamps are identical. If NULL, original row order is used.
Default: NULL.}

\item{session}{Character, character vector, or NULL. Column name(s) for
explicit session grouping (e.g. \code{"course"} or
\code{c("course", "semester")}). When combined with \code{time},
sessions are further split by time gaps. Default: NULL.}

\item{time_threshold}{Numeric. Maximum gap in seconds between consecutive
events before a new session starts. Only used when \code{time} is
provided. Default: 900 (15 minutes).}

\item{custom_format}{Character or NULL. Custom \code{strptime} format
string for parsing timestamps. Default: NULL (auto-detect).}

\item{is_unix_time}{Logical. If TRUE, treat numeric time values as Unix
timestamps. Default: FALSE (auto-detected for numeric columns).}

\item{unix_time_unit}{Character. Unit for Unix timestamps:
\code{"seconds"}, \code{"milliseconds"}, or \code{"microseconds"}.
Default: \code{"seconds"}.}
}
\value{
A list with class \code{"nestimate_data"} containing:
\describe{
\item{sequence_data}{Data frame in wide format (one row per session,
columns T1, T2, ...).}
\item{long_data}{The processed long-format data with session IDs.}
\item{meta_data}{Session-level metadata (session ID, actor).}
\item{time_data}{Parsed time values in wide format (if time provided).}
\item{statistics}{List with total_sessions, total_actions,
max_sequence_length, unique_actors, etc.}
}
}
\description{
Converts event log data (actor, action, time) into wide sequence format
suitable for \code{\link{build_network}}. Automatically parses timestamps,
detects sessions from time gaps, and handles tie-breaking.
}
\examples{
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")

}
\seealso{
\code{\link{build_network}}, \code{\link{prepare_onehot}}
}
