binner: Bin occurrences in geologic intervals

Description Usage Arguments Value Author(s) Examples

View source: R/binner.R

Description

Given a vector of fossil occurrences and time bins to represent geological ranges, returns the occurrence counts in each bin.

Usage

1
binner(x, bins)

Arguments

x

The vector containing occurrence times for a given species.

bins

A vector of time intervals corresponding to geological time ranges.

Value

A vector of occurrence counts for each interval.

Author(s)

Matheus Januario and Bruno do Rosario Petrucci

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
###
# 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.1, 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

# run the simulation
sim <- bd.sim(1, pp = 0.1, qq = 0.05, tMax = 15)

# sample it
sampled <- sample.species(sim = sim, rr = 1, tMax = 15, S = 1)

# bins vector
bins <- c(15.1, 12.3, 10, 7.1, 5.8, 3.4, 2.2, 0)

# result
binnedsample <- binner(sampled, bins)
binnedsample

### 
# just one more

# run the simulation
sim <- bd.sim(1, pp = function(t) {
  return(0.05 + 0.005*t)
}, qq = 0.05, tMax = 20)

# sample it
sampled <- sample.species(sim = sim, rr = 1, tMax = 20, S = 1)

# bins vector
bins <- c(15.1, 12.3, 10, 7.1, 5.8, 3.4, 2.2, 0)

# result
binnedsample <- binner(sampled, bins)
binnedsample

brpetrucci/paleobuddy documentation built on Aug. 8, 2020, 2:03 a.m.