dupMAP <- function(nbOutput){
## Loop over i folds
for(i in seq_along(nbOutput)){
## Loop over j best feature combinations
for(j in seq_along(nbOutput[[i]])){
## Loop over k individual runs
nbOutput[[i]][[j]]$dupMAP <- NA
for(k in 1:length(nbOutput[[i]][[j]][, unique(run)])){
## MAP with duplicates allowed
nbOutput[[i]][[j]][run == unique(run)[k], "dupMAP" := ifelse(posterior == max(posterior), TRUE, FALSE),
by = c("run", "Barcode")]
## Posterior of 0 still means reject assignment and send to no assignment category
nbOutput[[i]][[j]][run == unique(run)[k], "temp" := ifelse(posterior == 0 & dupMAP == TRUE, TRUE, FALSE)]
nbOutput[[i]][[j]][temp == TRUE, dupMAP := NA]
nbOutput[[i]][[j]][, temp := NULL]
}
}
## Progress message
message(paste0("Completed dupMAP for fold ", i, "/", length(nbOutput)))
}
return(nbOutput)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.