mt_as_track_attribute {move2} | R Documentation |
Move one or more columns to track attributes or event attributes
Description
-
mt_as_track_attribute
: move a column from the event to the track attributes -
mt_as_event_attribute
: move a column from the track to the event attributes
Usage
mt_as_track_attribute(x, ..., .keep = FALSE)
mt_as_event_attribute(x, ..., .keep = FALSE)
Arguments
x |
The move2 object |
... |
the names of columns to move, it is also possible to use |
.keep |
a logical if the variables also kept in their original location |
Details
When one or more of the selected columns contain more then one unique value per track an error is raised.
Value
An object of the class move2
with the column(s) moved
See Also
-
mt_track_data()
to retrieve the track attribute table -
mt_set_track_data()
to replace attribute table with new values
Examples
sim_data <- mt_sim_brownian_motion()
sim_data$sex <- "female"
## different ways to move column "sex" from event to track attribute
sim_data |> mt_as_track_attribute(sex)
sim_data |> mt_as_track_attribute(starts_with("s"))
sim_data |> mt_as_track_attribute(any_of(c("sex", "age")))
[Package move2 version 0.3.0 Index]