#' An intermediate function for conflicts of interest identification
#'
#' @param assignmentsDF The complete reviewer assignments dataset (as generated by combineOutputs)
#' @param conflictsDF A data.frame() containing conflicts of interest with columns for applicant's "Name" (format "Lastname, Firstname") and "Faculty.Member.1" through "Faculty.Member.6"
#' @return A matrix with boolean values indicating where assigned reviewer/applicant pairs constitute a conflict of interest (TRUE = a conflict of interest was detected).
#' @examples
#' \dontrun{
#' complete.design = combineOutputs(reviewers = reviewers,
#' assignments1 = s.des.names,
#' assignments2 = f.des.names)
#' }
#' @importFrom dplyr filter
#' @export
#
# A function to identify where conflicts of interest exist
# assignmentsDF is the complete reviewer assignments dataset
# conflictsDF is the conflictsOfInterest dataset (derived from application info)
findConflicts = function(conflictsDF,
assignmentsDF){
# Generate empty COI matrix
myConflicts = matrix(NA,
nrow = length(unique(conflictsDF$Name)), # Rows = students
ncol = 12) # Columns = their specific faculty advisor interests. Should just be 6 but could be 12 if people submitted 2 applications
for(i in 1:length(unique(conflictsDF$Name))){ # For each unique student...
student = unique(conflictsDF$Name)[i] # ...find student name
fullStudentRows = filter(conflictsDF, Name == student) # Isolate that student's row(s) in the GARD data
fullStudentCOIs = as.vector(as.matrix(fullStudentRows[,2:7])) # Find all COI faculty reviewers
for(j in 1:length(fullStudentCOIs)){ # For all COI reviewers
r = fullStudentCOIs[j] # Isolate the reviewer in question
rAssignments = as.vector(as.matrix(assignmentsDF[assignmentsDF$Name == r,])) # Find all students that reviewer r will review
if(student %in% rAssignments){ # If the student in question is listed as a reviewee for that COI reviewer,
myConflicts[i,j] = TRUE # Then we have a conflict of interest!
}else{
myConflicts[i,j] = FALSE# Otherwise, no conflict of interest exists.
}
}
}
return(myConflicts) # Return matrix of conflicts
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.