Learn R Programming

sift (version 0.1.0)

conjecture: Specialized "long to wide" reshaping

Description

On the surface, conjecture() appears similar to tidyr::pivot_wider(), but uses different logic tailored to a specific type of dataset:

  • column corresponding to names_from contains only 2 levels

  • there is no determinate combination of elements to fill 2 columns per row.

See vignette("conjecture") for more details.

Usage

conjecture(data, sort_by, names_from, names_first)

Arguments

data

A data frame to reshape.

sort_by

Column name, as symbol. Plays a similar role as values_from in pivot_wider(), but also serves as sorting dimension for underlying conjecture algorithm.

names_from

Column name, as symbol. Used to differentiate anterior/posterior observations. Column must only contain 2 levels (missing values not allowed).

names_first

level in variable specified by names_from indicating anterior observation.

Value

An object of the same type as data.

Details

conjecture() uses the following routine to match elements:

  1. Values in sort_by are separated into two vectors: anterior and posterior.

  2. Each anterior element is matched with the closest posterior element measured by sort_by.

Examples

Run this code
# NOT RUN {
# See vignette("conjecture") for more examples

conjecture(comms, timestamp, type, "send")
# }

Run the code above in your browser using DataLab