Description Usage Arguments Details Value Examples
Cleanup times in population data frame, so that they are regularly spaced and stop at the correct time, using either means to interpolate new data points or previous value for events. We assume when the data frame stops before end.time that the state then remaining unchanged.
1 2 3 4 5 6 7 8 9 10 11 | cleanup_times(
populations,
are.events,
timestep = 1,
end.time = max(populations$time),
times = seq(from = min(populations$time), to = end.time, by = timestep)
)
cleanup_events(populations, ...)
cleanup_timesteps(populations, ...)
|
populations |
- a data frame with columns corresponding to different population segments and a 'time' column |
are.events |
- whether the times in the data frame are events (therefore should take last event to determine state) or not (therefore interpolate) |
timestep |
- (optionally) timestep required for times - default 1 |
end.time |
- (optionally) end of simulation time required - default
|
times |
- (optionally) vector of times to be reproduced - default
|
... |
- pass through arguments for |
cleanup_events()
cleans up times of an event-based population data
frame, cleanup_timesteps()
cleans up times of an timestep-based
population data frame.
Revised data frame with correct timings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | growth <- function(latest.df, growth.rate) {
current.count <- latest.df$count
growth.num <- current.count * growth.rate
next.count <- current.count + growth.num
next.time <- latest.df$time + 1
new.df <- data.frame(time=next.time, count=next.count)
finished <- next.count == 0
list(updated.pop=new.df, end.experiment=finished)
}
df <- data.frame(time=0, count=1)
results <- run_simulation(growth, df, 100, growth.rate=0.1)
plot_populations(results)
short.results <- cleanup_timesteps(results, timestep=20, end.time=80)
plot_populations(short.results, new.graph=FALSE, lty=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.