conjecture.Rd
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.
conjecture(data, sort_by, names_from, names_first)
data | A data frame to reshape. |
---|---|
sort_by | Column name, as symbol. Plays a similar role as |
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 |
An object of the same type as data
.
conjecture()
uses the following routine to match elements:
Values in sort_by
are separated into two vectors: anterior and posterior.
Each anterior element is matched with the closest posterior element measured by sort_by
.
# See vignette("conjecture") for more examples conjecture(comms, timestamp, type, "send")#> # A tibble: 24,958 x 4 #> station msg_code send receive #> <chr> <int> <dttm> <dttm> #> 1 D 2537 1999-01-21 03:37:57 1999-02-15 21:56:29 #> 2 C 720 1999-01-24 11:52:07 1999-02-22 12:24:57 #> 3 D 2531 1999-01-26 11:50:58 1999-02-09 07:14:33 #> 4 D 2992 1999-01-27 02:48:56 1999-02-22 12:05:55 #> 5 A 2262 1999-01-27 09:19:56 1999-02-11 19:43:42 #> 6 B 1785 1999-01-27 12:11:04 1999-02-07 03:07:50 #> 7 C 1624 1999-01-27 15:33:09 1999-02-20 05:07:54 #> 8 C 2280 1999-01-27 20:06:18 1999-02-18 11:25:13 #> 9 B 1170 1999-01-28 00:55:33 NA #> 10 B 2137 1999-01-28 02:30:30 1999-02-26 17:13:21 #> # … with 24,948 more rows