View source: R/extract_histories.R
extract_histories | R Documentation |
Convert Unique Event Identifier Event Data into Multiple Source Capture Recapture Histories
extract_histories(datasets, count_name, cov_names = c())
datasets |
An ordered list of capture event datasets. The first j-1 columns of the jth dataset should be a 0 or 1 indicator of beng captured in a previous event. |
count_name |
The name of the column holding the counts of the number of individuals. |
cov_names |
A character vector of column names for covariates to stratify by. |
A dataframe. The first length(datasets) columns of which contain all possible permutations of capture histories. The "__count__" column contains the number of observed cases. Other columns are the stratifying covariates.
# First sample dat1 <- data.frame( count=c(55,43), c1=c("m","f"), stringsAsFactors = FALSE ) # Second sample dat2 <- data.frame( id1=c(1,0,1,0), count=c(10,11,5,12), c1=c("m","m","f","f"), stringsAsFactors = FALSE ) # Third Sample dat3 <- data.frame( id1=c(1,0,1,0,1,0,1,0), id2=c(1,1,1,1,0,0,0,0), count=c(2,3,4,3,2,30,4,30), c1=c("m","m","f","f","m","m","f","f"), stringsAsFactors = FALSE ) # Fourth Sample dat4 <- data.frame( id1=c(1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0), id2=c(1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0), id3=c(1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0), count=c(1,1,1,1,0,1,0,0,1,1,1,1,1,0,1,10), c1=c("m","m","f","f","m","m","f","f","m","m","f","f","m","m","f","f"), stringsAsFactors = FALSE ) # Combine 4 capture recatpure events together datasets <- list(dat1,dat2,dat3,dat4) # Get four sample capture recapture histories from unique event observations extract_histories(datasets, "count") # Stratify by a covariate extract_histories(datasets, "count", cov_names="c1") # Two sample capture recapture extract_histories(datasets[1:2], "count", cov_names="c1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.