Three groups issue
on Monday, September 19th, 2022 1:00 | by Silvia Marcato
if(NofGroups == 3 & length(unique(groupdescriptions))==2){
doubleton <- list()
singleton <- list()
if (groupdescriptions[1] == groupdescriptions[2]) {
doubleton = c(unique(groupdescriptions[1], groupdescriptions[2]),
groupnames[1], groupnames[2])
singleton = c(groupdescriptions[3], groupnames[3])
} else if (groupdescriptions[2] == groupdescriptions[3]) {
doubleton = c(unique(groupdescriptions[2], groupdescriptions[3]),
groupnames[2], groupnames[3])
singleton = c(groupdescriptions[1], groupnames[1])
} else {
doubleton = c(unique(groupdescriptions[1], groupdescriptions[3]),
groupnames[1], groupnames[3])
singleton = c(groupdescriptions[2], groupnames[2])
}
}
Given three descriptions, splits them into three variables. Two out of three of these are the same while the other is not: the single set to be compared to the two “identical” sets is emplaced in the singleton list while the other two sets are emplaced in the doubleton list.
Category: R code
Leave a Reply