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

View source: R/AdultAnnualSurv.R

AdultAnnualSurvR Documentation

Conversion of adult capture data into the correct format for modeling annual survival

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 annual survival.

Usage

AdultAnnualSurv(dbpath, mortcol, dateformat, yearstart, yearend, idcol,
  capcol, fatecol, censors, plot, title)

Arguments

dbpath

path to data.frame (csv) that contains a column of unique animal identifier, start date, mortality date, and cause of mortality (if applicable). If mortality has not occured, mortality date will be Sys.Date(), and event indicator will be 0

mortcol

name of column where mortality date exists

dateformat

format of mortality and capture dates

yearstart

year (YYYY) to begin modelling survival.

yearend

year (YYYY) to end modelling survival

idcol

name of column where unique animal identifiers are located

capcol

name of column where capture date is stored

fatecol

name of column where fate/cause of mortality occurs

censors

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

plot

logical. TRUE/FALSE. If TRUE, function will generate bar plot of yearly survival

title

desired title of survival plot (character)

Value

Returns a data.frame with animal ID, start date of modeling, end date of modeling, status of animal (alive = 0, dead = 1), and number of months alive during time period

Examples

AdultSurv<-AdultAnnualSurv(dbpath = 'C:/Desktop/yourdb', mortcol = 'MortDate', dateformat = "%m/%d/%Y", yearstart = 2019, yearend = 2020 , idcol = 'AID', capcol = 'CaptureDate',fatecol = 'Cause', censors = c("CollarFailure", "CaptureMort"), plot = TRUE, title = 'Survival of Bighorn Sheep')


khuggler/Ovis documentation built on Nov. 30, 2023, 7:41 p.m.