Learn R Programming

ValidationExplorer (version 0.1.1)

mask_by_spp: mask_by_spp: simulate a validation design

Description

mask_by_spp: simulate a validation design

Usage

mask_by_spp(data, props_to_val)

Value

A list containing two elements: final_df and data_sum. final_df

is a copy of the input data masked according to the validation design supplied by props_to_val. The second output, data_sum is a dataframe containing a summary of the number and proportion of ambiguous (i.e., not validated) recordings. It provides a check that the masking function is working correctly.

Arguments

data

A dataframe containing the columns site, visit, true_spp, id_spp, count

props_to_val

a vector containing the proportion of recordings to validate for each species

Examples

Run this code
library(dplyr)

dat <- sim_dat()$full_df

head(dat)

dat <- dat %>% tidyr::uncount(weights = count, .remove = FALSE)
val_dat <- mask_by_spp(dat, props_to_val = c(rep(.1, 4), rep(.4, 4)))

val_dat$final_df %>% group_by(id_spp) %>%
  summarize(prop_vald = sum(!is.na(true_spp))/n())

Run the code above in your browser using DataLab