start_event: Determine the starting point for each time series.

View source: R/acf.R

start_eventR Documentation

Determine the starting point for each time series.

Description

Determine the starting point for each time series.

Usage

start_event(
  data,
  column = "Time",
  event = "Event",
  label = "start.event",
  label.event = NULL,
  order = TRUE,
  newcode = TRUE
)

Arguments

data

A data frame.

column

Test string, name of the column that describes the order withing the time series. Default is 'Time'.

event

A text string or vector indicating the columns that define the unique time series. Default is 'Event'.

label

The name of the new column with the start point of each time series. Default is 'start.event'.

label.event

In case event is not a single column, providing a text string will add a column with this name that defines unique time series. Default is NULL (no new column for time series is created).

order

Logical: whether or not to order each time series. Default is TRUE, maybe set to FALSE with large data frames that are already ordered.

newcode

Logical: whether or not to use the new (and hopefully faster) code.

Value

Data frame.

Note

When working with large data frames, it may be worth installing the package data.table. Although not required for the package, the function start_event will check if data.table is available and will use it's much faster function rbindlist. This speeds up the function start_event. Run the command install.packages('data.table', repos='http://cran.us.r-project.org') in the command window for installing the package data.table.

Author(s)

Jacolien van Rij

See Also

Other functions for model criticism: acf_n_plots(), acf_plot(), acf_resid(), derive_timeseries(), resid_gam(), start_value_rho()

Examples

data(simdat)
head(simdat)
simdat <- simdat[sample(1:nrow(simdat)),]
simdat$Condition <- relevel(factor(simdat$Condition), ref="0")
contrasts(simdat$Condition) <- "contr.poly"
contrasts(simdat$Condition)
test <- start_event(simdat, event=c('Subject', 'Trial'), label.event='Event') 
contrasts(test$Condition)
head(test)
test <- start_event(simdat, event="Subject")
test <- start_event(simdat, event=c('Subject', 'Trial'))

itsadug documentation built on June 17, 2022, 5:05 p.m.