I am working in R from a csv that characterizes distinct events (labeled below as "A", "B", "C"). I'm interested in the sequence of behaviors ("x", "y", "z" below) within an event, but events may be divided among more than one row. For the question I am interested in I would like to line up the full sequence of behaviors in a single row for each event. I'm having trouble figuring out how to do this in R.
This is what my data look like:
Behavior 1 | Behavior 2 | Behavior 3 | Behavior 4 | Behavior 5
A | x | x | | |
A | y | | | |
B | y | x | | |
C | y | z | x | |
C | x | | | |
This is what I would like my data to look like:
Behavior 1 | Behavior 2 | Behavior 3 | Behavior 4 | Behavior 5
A | x | x | y | |
B | y | x | | |
C | y | z | x | x |
Thanks in advance for the help!