AdultSeasonalSurv: Conversion of adult capture data into the correct format for...

Description Usage Arguments Value Examples

View source: R/AdultSeasonalSurv.R

Description

Convert capture and cause-specific mortality data of adults into the proper format for conducting survival analysis.This function will convert raw data that contains start dates and mortality dates of individual animals and transform it into the proper format required by package survival to model seasonal survival.

Usage

1
2
3
AdultSeasonalSurv(data, uni, UAIDcol, startcol, mortcol, yearstart,
  yearend, seasons = c("winter", "summer"), winterstart, winterend,
  cause, dateformat, plot, title)

Arguments

data

data.frame that contains a column of unique animal identifier, start date, mortality date, and cause of mortality

uni

vector of unique animal identifiers

UAIDcol

name of column where unique animals ids are stored

startcol

name of column with capture date

mortcol

name of column that contains the date of mortality

yearstart

year desired to begin modeling survival (e.g. beginning year of study)

yearend

year desired to end modeling survival

seasons

c('winter', 'summer')

winterstart

month in numeric format that is desired to start winter (e.g. 11)

winterend

month in numeric format that is desired for winter to end (e.g. 05)

cause

vector of causes that require censoring (e.g. collar_failure, capturemort, etc.)

dateformat

format of startcol and mortcols

plot

Logical. TRUE/FALSE. Whether a barplot of cumulative survival is desired

title

desired title of plot

Value

Returns a data.frame with animal ID, Year of survival, start date of modeling, end date of modeling, time alive (months), and status of animal (alive/censored = 0, dead = 1)

Examples

1
AdultSeasonal<-AdultSeasonalSurv(data = data, startcol = 'CaptureDate',uni = uni, UAIDcol = "UAID", mortcol = 'MortalityDate', yearstart = 2015, yearend = 2019, seasons = c('winter', 'summer'), winterstart = 11, winterend = 05, cause = c("CollarFailure", 'CaptureMort'))

khuggler/TediousEcology documentation built on July 10, 2021, 12:34 a.m.