abundance2pres.RdConverts abundance data to presence data with imperfect detection. Considering imperfect detection per individual: if any of them are detected it is considered as presence unit; if none of them are detected it is considered as absence unit.
abundance2pres(abun, ipd)Returns a data frame with the abundance of each unit and the presence/absence data.
set.seed(1111)
#Create random values for the required variables:
#data frame with abundance values and the imperfect detection value
sample_id <- sample(1:40, size = 10, replace = FALSE)
abundance <- sample(0:6, size = 10, replace = TRUE)
abun_df <- data.frame(id = sample_id, abun = abundance)
head(abun_df, n = 10)
#> id abun
#> 1 26 6
#> 2 36 4
#> 3 6 0
#> 4 40 4
#> 5 31 6
#> 6 1 3
#> 7 13 4
#> 8 24 3
#> 9 2 1
#> 10 18 5
ipd <- 0.5
#Create a new data frame with a new column indicating if the species have been detected or not
pres_df <- abundance2pres(abun = abun_df, ipd = ipd)
head(pres_df, n = 10)
#> sampleID abundance occurrences
#> 1 26 6 1
#> 2 36 4 1
#> 3 6 0 0
#> 4 40 4 1
#> 5 31 6 1
#> 6 1 3 1
#> 7 13 4 0
#> 8 24 3 1
#> 9 2 1 0
#> 10 18 5 1