Extract.trajectory: Extract or Replace Parts of a Trajectory

Extract.trajectoryR Documentation

Extract or Replace Parts of a Trajectory

Description

Operators acting on trajectories to extract or replace parts.

Usage

## S3 method for class 'trajectory'
x[i]

## S3 method for class 'trajectory'
x[[i]]

## S3 replacement method for class 'trajectory'
x[i] <- value

## S3 replacement method for class 'trajectory'
x[[i]] <- value

Arguments

x

the trajectory object.

i

indices specifying elements to extract. Indices are numeric or character or logical vectors or empty (missing) or NULL.

Numeric values are coerced to integer as by as.integer (and hence truncated towards zero). Negative integers indicate elements/slices to leave out the selection.

Character vectors will be matched to the names and tags of the activities in the trajectory as by %in%.

Logical vectors indicate elements/slices to select. Such vectors are recycled if necessary to match the corresponding extent.

An empty index will return the whole trajectory.

An index value of NULL is treated as if it were integer(0).

value

another trajectory object.

Value

Returns a new trajectory object.

See Also

length.trajectory, get_n_activities, join.

Examples

x <- join(lapply(1:12, function(i)
  trajectory() %>% timeout(i)
))
x

x[10]                 # the tenth element of x
x[-1]                 # delete the 1st element of x
x[c(TRUE, FALSE)]     # logical indexing
x[c(1, 5, 2, 12, 4)]  # numeric indexing
x[c(FALSE, TRUE)] <- x[c(TRUE, FALSE)] # replacing
x


Bart6114/simmer documentation built on Oct. 2, 2024, 4:52 p.m.