convert_to_events: Sequence to dataframe

convert_to_eventsR Documentation

Sequence to dataframe

Description

A function that converts the id and sequence into a dataframe which contains the id, period, and event.

Usage

  convert_to_events(data, id_column, sequence_column)

Arguments

data

A data frame that has a column which is an identifier variable (ex. id), and another that represents a sequence with as a character class.

id_column

The column which is the identifier variable.

sequence_column

The column which contains the sequences as a character class.

Value

Returns a dataframe with 3 columns:

* id * period * event

Examples

  data("mvad")

  clustered_kmed <- mvad %>%
                          aggregate_sequences(format = "%Y-%m-%d",
                                              unit = "month",
                                              n_units = 1,
                                              summary_stats=FALSE) %>%
                          cluster_kmedoids(k = 5)

  patterns_kmed <- clustered_kmed %>%  filter_pattern(threshold = 0.5,
                                                        pattern_name = 'consensus')

  formatted_kmed <- patterns_kmed %>% format_sequence()

  formatted_kmed %>% convert_to_events("cluster", "consensus_pattern")

ilangurudev/approxmapR documentation built on March 22, 2022, 1:15 p.m.