Extract.trajectory {simmer} | R 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 values are coerced to integer as by Character vectors will be matched to the names of the activities in the
trajectory as by 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 |
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