R/combineOutputs.R

Defines functions combineOutputs

Documented in combineOutputs

#' A function to compile assignments from multiple iterations of `incomplete.block.design()`
#'
#' @param reviewers A data.frame() with columns `Name` ("Lastname, Firstname"), `Email`, and `type` (type indicates "Student" or "Faculty")
#' @param assignments1 A matrix (as generated by `getAssignments()`) containing applicant assignments for one reviewer pool (e.g. "Students")
#' @param assignments2 A matrix (as generated by `getAssignments()`) containing applicant assignments for a second reviewer pool (e.g. "Faculty")
#' @return A data.frame() containing one row per reviewer and "Name", "Email" and "type" columns that indicate reviewer identity, and then "Applicant-1" through "Applicant-i" columns where i is the number of applicants assigned to a single reviewer as defined by `alternatives.per.block` in `assignReviewers()`.
#' @examples
#' \dontrun{
#' complete.design = combineOutputs(reviewers = reviewers,
#' assignments1 = s.des.names,
#' assignments2 = f.des.names)
#' }
#' @import dplyr
#' @export
# 

combineOutputs = function(reviewers,
                          assignments1,
                          assignments2){
  # Get the names of reviewers in order
  IDs1 = dplyr::filter(reviewers, type == "Student")
  IDs2 = dplyr::filter(reviewers, type == "Faculty")
  # Add reviewer names to the assignments df
  des1df = data.frame(cbind(IDs1, assignments1))
  des2df = data.frame(cbind(IDs2, assignments2))
  # Combine student and faculty reviewers and assignments
  complete.design = rbind(des1df,
                          des2df)
  # Rename columns
  names(complete.design) = c("Name", "Email", "type",
                             paste(rep("Applicant", (ncol(complete.design)-3)),
                                   c(1:(ncol(complete.design)-3)),
                                   sep = "-"))
  # Convert to character data.frame
  complete.design[] = lapply(complete.design, as.character)
  return(complete.design)
}
ggeDCAA/ggeAdmit documentation built on Jan. 18, 2022, 9:02 p.m.