matchingR
matchingR copied to clipboard
galeShapley.collegeAdmissions() does not work properly when slots vector includes zero
I would like to set slots for some of the colleges zero, such as this:
studentPref <-
matrix(data = c(1,2,3,4,1,2,3,4,1,2,3,4), nrow = 4)
collegePref <-
matrix(data = c(1,2,3,1,2,3,1,2,3,1,2,3), nrow = 3)
galeShapley.collegeAdmissions(
studentPref = studentPref,
collegePref = collegePref,
slots = c(1,2,0,0))
which returns
$matched.colleges
$matched.colleges[[1]]
[1] 1
$matched.colleges[[2]]
[1] 2 3
$matched.colleges[[3]]
[1] NA 3
$matched.colleges[[4]]
[1] NA 3
$matched.students
[,1]
[1,] 1
[2,] 2
[3,] 4
I believe $matched.colleges[[3]], $matched.colleges[[4]] (both should be empty) as well as $matched.students[3,1] (should be 2) are wrong but I may be doing this wrong.
Setting slots = c(1,2,3,0) in the above example kind of works as expected, except for $matched.colleges[[4]] which should be empty instead of c(NA, NA).
Is it even possible to have zeros as elements of slots vector?