daisie_data_colonist_info_to_braching_times_table: Internal function

View source: R/daisie_data_to_tables.R

daisie_data_colonist_info_to_braching_times_tableR Documentation

Internal function

Description

Convert the non-header part of a daisie_data into a tabular format, containing, for each colonist, the branching times. This excludes the time of colonisation.

Usage

daisie_data_colonist_info_to_braching_times_table(daisie_data_colonist_info)

Arguments

daisie_data_colonist_info

an element of a daisie_data, that is not the first element (the first element is of type daisie_data_header).

Details

Due to the coding of DAISIE, this is not straightforward:

  • If there are no colonisations, an empty table is produced

  • If there is one colonisation, the event_times are used

  • If there are two or more colonisations, the event_times in the all_colonisations list is used

Value

a table with as much rows as branching times

Author(s)

Richèl J.C. Bilderbeek

See Also

use daisie_data_colonist_info_to_colonisation_times_table to obtain the colonisation times of the colonists

Examples

set.seed(
  1,
  kind = "Mersenne-Twister",
  normal.kind = "Inversion",
  sample.kind = "Rejection"
)
total_time <- 1
daisie_mainland_data <- sim_island_with_mainland(
  total_time = total_time,
  m = 10,
  island_pars = c(1, 1, 10, 0.1, 1),
  mainland_ex = 1,
  mainland_sample_prob = 1,
  mainland_sample_type = "undiscovered",
  replicates = 1,
  verbose = FALSE
)
ideal_daisie_data <- daisie_mainland_data$ideal_multi_daisie_data[[1]]

# We need a non-header daisie_data
testthat::expect_true(length(ideal_daisie_data) > 1)
# Take the first non-header daisie_data
daisie_data_colonist_info <- ideal_daisie_data[[2]]
t <- daisie_data_colonist_info_to_braching_times_table(
  daisie_data_colonist_info = daisie_data_colonist_info
)
testthat::expect_true("colonist_index" %in% names(t))
testthat::expect_true("branching_times" %in% names(t))
# Do not include the colonisation
testthat::expect_false(total_time %in% t$branching_times)


joshwlambert/DAISIEmainland documentation built on July 14, 2024, 5:40 p.m.