Title: | Coding 'ABA' Patterns for Sequence Data |
---|---|
Description: | Provides a suite of functions for analyzing sequences of events. Users can generate and code sequences based on predefined rules, with a special focus on the identification of sequences coded as 'ABA' (when one element appears, followed by a different one, and then followed by the first). Additionally, the package offers the ability to calculate the length of consecutive 'ABA'-coded sequences sharing common elements. The methods implemented in this package are based on the work by Ziembowicz, K., Rychwalska, A., & Nowak, A. (2022). <doi:10.1177/10464964221118674>. |
Authors: | Andrew Pilny [aut, cre]
|
Maintainer: | Andrew Pilny <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2025-02-28 04:15:48 UTC |
Source: | https://github.com/cran/abasequence |
This function counts the number of occurrences of each unique event in a sequence. The result is a dataframe with two columns: ID and Frequency.
count_events(event_vector)
count_events(event_vector)
event_vector |
A numeric vector representing a sequence of events. |
A dataframe with two columns: ID and Frequency, showing the number of occurrences of each event.
speaker_no <- c(3, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 3) count_events(speaker_no)
speaker_no <- c(3, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 3) count_events(speaker_no)
This function creates a dummy variable indicating whether a code represents 'ABA'.
create_is_aba(codes_df)
create_is_aba(codes_df)
codes_df |
A dataframe of binary codes generated by the generate_codes function. |
A dataframe of codes with an additional column indicating whether the code represents 'ABA'.
speaker_no <- c(3, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 3) sequences_df <- generate_sequences(speaker_no, 3) codes_df <- generate_codes(sequences_df) create_is_aba(codes_df)
speaker_no <- c(3, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 3) sequences_df <- generate_sequences(speaker_no, 3) codes_df <- generate_codes(sequences_df) create_is_aba(codes_df)
This function generates one of four possible codes for sequences: AAA, ABA, ABB, ABC.
generate_codes(sequences)
generate_codes(sequences)
sequences |
A dataframe containing the input sequences. |
A dataframe of sequences with their corresponding codes.
speaker_no <- c(3, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 3) sequences_df <- generate_sequences(speaker_no, 3) generate_codes(sequences_df)
speaker_no <- c(3, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 3) sequences_df <- generate_sequences(speaker_no, 3) generate_codes(sequences_df)
This function calculates the length of consecutive 'ABA'-coded sequences that share common elements in their ID. It assigns NA to non-'ABA' codes.
generate_length_aba(codes_df)
generate_length_aba(codes_df)
codes_df |
A dataframe of codes generated by the generate_codes function and processed by the create_is_aba function. |
A dataframe of codes with an additional column representing the length of 'ABA' sequences.
speaker_no <- c(3, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 3) sequences <- generate_sequences(speaker_no, 3) codes <- generate_codes(sequences) aba <- create_is_aba(codes) length_aba <- generate_length_aba(aba)
speaker_no <- c(3, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 3) sequences <- generate_sequences(speaker_no, 3) codes <- generate_codes(sequences) aba <- create_is_aba(codes) length_aba <- generate_length_aba(aba)
This function generates sequences of a given length from a numeric vector.
generate_sequences(event_vector, sequence_length)
generate_sequences(event_vector, sequence_length)
event_vector |
A numeric vector representing a sequence of events. |
sequence_length |
An integer representing the length of sequences to generate. Currenlty only supported with sequence lengths of 3 |
A dataframe containing the sequences and their ID.
speaker_no <- c(3, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 3) generate_sequences(speaker_no, 3)
speaker_no <- c(3, 2, 3, 1, 4, 2, 4, 1, 4, 3, 2, 3) generate_sequences(speaker_no, 3)