I have two original vectors with three values each (6 total). There are 20 total ways to rearrange the six total values into two new sets of vectors with three elements each.
For each of these combinations of three, I need to create a new vector that lists the ranks of each of the elements in relation to the ranks of all elements. For example, the complete set values is [36,39,55,60,70,73] and one combination of three is [36,55,70]. Since this subset contains the first, third, and fifth ranked values, I need a vector that will be [1,3,5]. Hope this makes sense.
I was hoping trying to figure out with some kind of code involving lapply but can't get it to work. Please help!
#list of values for those who took drug
drug<-c(36, 60, 39)
#list of values for those who took placebo
placebo<-c(73, 55, 70)
#all values combined into one vector, in order
drugandplacebo<-c(drug,placebo)
drugandplacebo<-sort(drugandplacebo)
drugandplacebo
order(drugandplacebo)
#list with all all combinations of three for drug
drugcomb <- combn(drugandplacebo,3,simplify = FALSE)
drugcomb<-as.numeric(drugcomb)
drugcomb
#list with all remaining values not in drugcomb
placcomb <- lapply(drugcomb, function(x) drugandplacebo[!drugandplacebo %in% x])
placcomb<-as.numeric(placcomb)
placcomb
combn(1:6, 3, simplify=FALSE)
, and you get exactly what you want. - Edward Carney