###
# first let us create some artificial occurrence data and check
# occurrence vector
x <- c(5.2, 4.9, 4.1, 3.2, 1, 0.2)
# bins vector
bins <- c(6, 5, 4, 3, 2, 1, 0)
# result
binnedSamp <- binner(x, bins)
binnedSamp
###
# it should work with any type of number in bins
# occurrence vector
x <- c(6.7, 5.03, 4.2, 3.4, 1.2, 0.4)
# bins vector
bins <- c(7.2, 6.7, 5.6, 4.3, 3.2, sqrt(2), 1, 0)
# result
binnedSamp <- binner(x, bins)
binnedSamp
###
# let us try with a real simulated species fossil record
# set seed
set.seed(1)
# run the simulation
sim <- bd.sim(1, lambda = 0.1, mu = 0.05, tMax = 15)
# sample it
sampled <- sample.clade(sim = sim, rho = 1, tMax = 15, S = 1)$SampT
# bins vector
bins <- c(15.1, 12.3, 10, 7.1, 5.8, 3.4, 2.2, 0)
# result
binnedsample <- binner(sampled, bins)
binnedsample
Run the code above in your browser using DataLab