prepareSequences {distantia}R Documentation

Prepare sequences for a comparison analysis.


This function prepares two or more multivariate time-series that are to be compared. It can work on two different scenarios:


  sequence.A = NULL, = "A",
  sequence.B = NULL, = "B",
  merge.mode = "complete",
  sequences = NULL,
  grouping.column = NULL,
  time.column = NULL,
  exclude.columns = NULL,
  if.empty.cases = "zero",
  transformation = "none",
  paired.samples = FALSE,
  same.time = FALSE



dataframe containing a multivariate time-series.

character string with the name of sequence.A. Will be used as identificator in the id column of the output dataframe.


dataframe containing a multivariate time-series. Must have overlapping columns with sequence.A with same column names and units.

character string with the name of sequence.B. Will be used as identificator in the id column of the output dataframe.


character string, one of: "overlap", "complete" (default option). If "overlap", sequence.A and sequence.B are merged by their common columns, and non-common columns are dropped If "complete", columns absent in one dataset but present in the other are added, with values equal to 0. This argument is ignored if sequences is provided instead of sequence.A and sequence.B.


dataframe with multiple sequences identified by a grouping column.


character string, name of the column in sequences to be used to identify separates sequences within the file. If two sequences are provided through the arguments sequence.A and sequence.B, this argument defines the name of the grouping column in the output dataframe. If two or several sequences are provided as a single dataframe through the argument sequences, then grouping.column must be a column in this dataset.


character string, name of the column with time/depth/rank data. If sequence.A and sequence.B are provided, time.column must have the same name and units in both dataframes.


character string or character vector with column names in sequences, or squence.A and sequence.B, to be excluded from the transformation.


character string with two possible values: "omit", or "zero". If "zero" (default), NA values are replaced by zeroes. If "omit", rows with NA data are removed.


character string. Defines what data transformation is to be applied to the sequences. One of: "none" (default), "percentage", "proportion", "hellinger", and "scale" (the latter centers and scales the data using the scale function).


boolean. If TRUE, the function will test if the datasets have paired samples. This means that each dataset must have the same number of rows/samples, and that, if available, the time.column must have the same values in every dataset. This is only mandatory when using the functions distancePairedSamples or workflowPsi with paired.samples = TRUE after preparing the sequences. The default setting is FALSE.


boolean. If TRUE, samples in the sequences to compare will be tested to check if they have the same time/age/depth according to time.column. This argument is only useful when the user needs to compare two sequences taken at different sites but same time frames.


A dataframe with the multivariate time series. If squence.A and sequence.B are provided, the column identifying the sequences is named "id". If sequences is provided, the time-series are identified by grouping.column.


Blas Benito <>


#two sequences as inputs

AB.sequences <- prepareSequences(
 sequence.A = sequenceA, = "A",
 sequence.B = sequenceB, = "B",
 merge.mode = "complete",
 if.empty.cases = "zero",
 transformation = "hellinger"

#several sequences in a single dataframe
MIS.sequences <- prepareSequences(
 sequences = sequencesMIS,
 grouping.column = "MIS",
 if.empty.cases = "zero",
 transformation = "hellinger"

[Package distantia version 1.0.2 Index]