Learn R Programming

timeordered (version 1.0.1)

randomizetimes: Resamples data based on event time.

Description

Produces a new event list from an existing event list with resampled event times given certain constraints on randomization. Effectively re-orders pairs of start/stop times between different vertices.

Usage

randomizetimes(raw, withinvertexfrom, byvertexfrom, withreplacement)

Value

An event list of the same size as raw with event times resampled. Resampling does not break the relationship between start and stop time; i.e. resampled events will have the same duration as original events.

Arguments

raw

A raw event list to be resampled. Contains four columns: VertexFrom, VertexTo, TimeStart, TimeStop

withinvertexfrom

If true, resamples within data subsets where VertexFrom is fixed; otherwise resamples within all data.

byvertexfrom

If true, subsets of data for withinvertexfrom are obtained using VertexFrom; if false, using VertexTo.

withreplacement

Samples with or without replacement.

Author

Benjamin Blonder bblonder@email.arizona.edu.

See Also

randomizeidentities,rarefy

Examples

Run this code
data(ants)
allindivs <- c(union(as.character(ants$VertexFrom), as.character(ants$VertexTo)), "NULL1", "NULL2")
rt <- randomizetimes(ants,withinvertexfrom=TRUE,byvertexfrom=TRUE,withreplacement=TRUE)
g <- generatetonetwork(rt, allindivs)
plottonet(g)


Run the code above in your browser using DataLab