seq_adj: Adjust Sequence to Target

View source: R/eratosthenes.R

seq_adjR Documentation

Adjust Sequence to Target

Description

Given an "input" sequence of elements and another "target" seqeunce that contains fewer elements in a different order, shift the order of the input sequence to match that of the target, keeping all other elements as proximate to one another as possible. This adjusted ranking is accomplished using piecewise linear interpolation between joint elements ranks. That is, joint rankings are plotted, with input rankings along the x axis and target rankings on the y axis. Remaining rankings in the input sequence are assigned a ranking of y based on the piecewise linear function between joint rankings. If the rank order of elements in the target are identical to those in the input, the result is identical to the input. A minimum number of three joint elements in both the input and target are required.

Usage

seq_adj(input, target)

## S3 method for class 'character'
seq_adj(input, target)

Arguments

input

A vector of elements in a sequence.

target

A vector of elements in a sequence, containing at least three of the same elements as input.

Value

A vector of the adjusted sequence.

Examples

x <- c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J") # the input sequence
y <- c("D", "A", "J") # the target sequence

seq_adj(x, y)


eratosthenes documentation built on June 28, 2025, 1:08 a.m.