Learn R Programming

move2 (version 0.4.4)

mt_as_track_attribute: 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)

Value

An object of the class move2 with the column(s) moved

Arguments

x

The move2 object

...

the names of columns to move, it is also possible to use helpers.

.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.

See Also

  • mt_track_data() to retrieve the track attribute table

  • mt_set_track_data() to replace attribute table with new values

Examples

Run this code
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")))

Run the code above in your browser using DataLab