aggregateSimulation: Aggregates the output of 'simulatePopulation'.

View source: R/aggregateSimulation.R

aggregateSimulationR Documentation

Aggregates the output of simulatePopulation.

Description

Takes the output of simulatePopulation and aggregates it into centimetres by following a sediment accumulation rate produced by simulateAccumulationRate. It further samples it at given depth intervals. It intends to simulate a pseudo-realistic sedimentation of the pollen produced by the simulation, and to apply a pollen-sampling pattern to a virtual pollen core.

Usage

aggregateSimulation(
  simulation.output=NULL,
  accumulation.rate=NULL,
  sampling.intervals=1
  )

Arguments

simulation.output

list, output of simulatePopulation.

accumulation.rate

dataframe, output of simulateAccumulationRate.

sampling.intervals

integer, numeric vector, depth interval or intervals between consecutive samples in centimetres. If 1, all samples are returned, if 2, returned samples are separated by 1 cm.

Details

The function uses the values in the grouping column of the simulateAccumulationRate output to aggregate together (by computing the mean) as many samples as cases in grouping have the same identificator. Output samples are identified by the average age of the samples within the given centimetre.

Value

A list of dataframes with as many rows as virtual taxa were produced by simulatePopulation, and the following columns: column 1 is the original data, column 2 is the original data aggregated by the accumulation rate, columns 3 to n are the different sampling intervals defined by the user.

Author(s)

Blas M. Benito <blasbenito@gmail.com>

See Also

simulateAccumulationRate, simulatePopulation

Examples


#getting example data
data(simulation)
data(accumulationRate)

#aggregating first simulation outcome
sim.output.aggregated <- aggregateSimulation(
 simulation.output = simulation[1],
 accumulation.rate = accumulationRate,
 sampling.intervals = c(2,6))

#comparing simulations
par(mfrow = c(3,1))
#notice the subsetting of the given column of the input list
plot(sim.output.aggregated[[1,1]]$Time,
 sim.output.aggregated[[1,1]]$Pollen,
 type = "l",
 xlim = c(500, 1000),
 main = "Annual"
 )
plot(sim.output.aggregated[[1,2]]$Time,
 sim.output.aggregated[[1,2]]$Pollen,
 type = "l",
 xlim = c(500, 1000),
 main = "2cm"
 )
plot(sim.output.aggregated[[1,3]]$Time,
 sim.output.aggregated[[1,3]]$Pollen,
 type = "l",
 xlim = c(500, 1000),
 main = "6cm"
 )

#check differences in nrow
nrow(sim.output.aggregated[[1,1]]) #original data
nrow(sim.output.aggregated[[1,2]]) #2cm
nrow(sim.output.aggregated[[1,3]]) #6cm intervals


virtualPollen documentation built on March 18, 2022, 6:16 p.m.