Learn R Programming

contact (version 1.2.1)

potentialDurations: Identify Potential Contact Durations

Description

This function uses the output from dist2All to determine the potential maximum number of direct-contact durations between individuals in a data set. The max number of durations potentially observed is the number of TSWs both individuals (or an individual and fixed area) were observed at the same time over the study period/temporal block. The output of this function is required for using the "chisq" test argument in the contactTest function.

Usage

potentialDurations(
  x,
  blocking = FALSE,
  blockLength = 1,
  blockUnit = "hours",
  distFunction = "dist2All_df"
)

Arguments

x

Output from the dist2All or dist2Area function. Can be either a data frame or non-data-frame list.

blocking

Logical. If TRUE, contacts will be evaluated for temporal blocks spanning blockLength blockUnit (e.g., 6 hours) within the data set. Defaults to FALSE.

blockLength

Integer. Describes the number blockUnits within each temporal block. Defaults to 1.

blockUnit

Character string taking the values: "secs," "mins," "hours," "days," or "weeks." Describes the temporal unit associated with each block. Defaults to "hours."

distFunction

Character string taking the values: "dist2All_df", or "dist2Area_df." Describes the contact-package function used to generate x.

Value

Returns a data frame (or list of data frames if x is a list of data frames) with the following columns:

id

The unique ID of an individual observed in the data set.

potenDegree

The maximum degree possible for individual id based on the number of other individuals observed during the time period.

potenTotalContactDurations

The maximum number of contact durations individual id may experience during the time period.

potenContactDurations_...

The maximum number of contact durations individual id may experience with each specific individual/fixed area during the time period.

If blocking == TRUE, the following columns are appended to the output data frame described above:
block

Integer ID describing unique blocks of time during which contacts may occur.

block.start

The timepoint in x at which the block begins.

block.end

The timepoint in x at which the block ends.

Examples

Run this code
# NOT RUN {
data(calves)

calves.dateTime<-datetime.append(calves, date = calves$date, time =
    calves$time) #create a dataframe with dateTime identifiers for location foxes
    
calves.agg<-tempAggregate(calves.dateTime, id = calves.dateTime$calftag,
    dateTime = calves.dateTime$dateTime, point.x = calves.dateTime$x,
    point.y = calves.dateTime$y, secondAgg = 300, extrapolate.left = FALSE,
    extrapolate.right = FALSE, resolutionLevel = "reduced", parallel = FALSE,
    na.rm = TRUE, smooth.type = 1) #smooth locations to 5-min fix intervals.

calves.dist<-dist2All_df(x = calves.agg, parallel = FALSE, dataType = "Point",
    lonlat = FALSE) #calculate distance between all individuals at each timepoint
    
calves.potentialContacts<-potentialDurations(x = calves.dist, blocking = FALSE)
# }

Run the code above in your browser using DataLab