Description Usage Arguments Details Value
View source: R/event_stretches.R
Like, run length encoding (see rle
), this function finds stretches of a vector that contain consecutive repeats of a particular value. This function then procedes by classifying each event in a stretch as being closer to the beginning or end of the stretch.
1 |
X |
a data.table with columns for |
The contents of the columns in X
are as follows:
present | 1 for event, 0 for non-event. "Streaks" refer to consecutive 1's |
year | calendar year, or any time index indicating distance (space, time, etc) between events. |
now_ext | "now extinct"; integer vector of 1 or 0. 1 indicates that present contains the first 0 following a streak of 1's |
col | "colonization"; integer vector of 1 or 0. 1 indicates that present contains the first 1 at the beginning of a streak of 1's |
ext_dist_sign | "signed distance to extinction"; output from event_distance ; magntiude is distance in year s to non-event, with negative numbers indicating that closest non-event is in past (post-colonization) |
Returns a named list of length 2: stretch_id
and hybrid_part
.
The values in stretch_id
indicate the following:
-1 | the stretch is an extinction-only stretch, which can only happen for a stretch at the beginning of a vector b/c the first element in present is 1, so there is no initial 0-to-1 transition |
-2 | colonization-only stretch; only occurs at end of vector where last value in present is 1 (no extinction) |
1,2,... | a hybrid stretch, occurs for a stretch in present that is begun and terminated by a 0; this is the most generic case; the integer value serves to distinguish among multiple hybrid stretches |
When the stretch is classified as a "hybrid", some of the 1's will be closer to the initial 0 than to the terminating 0. Those closer to the inital 0 are considered "post-colonization", whereas those closer to the final 0 are considered "pre-extinction". Proximiting is defined using year
. Ties are ~arbitrarily attributed to post-coloniztion.
The values in hybrid_part
indicate the following:
1 | post-colonization |
2 | pre-extinction |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.