My question follows a recent thread on code to compute pairwise differences
between elements of a group. The final code, suggested by Dimitris
Rizoupolos building on the script proposed by Marcus Hudec was:
unlist(tapply(A$Values, A$Group, function(x) { out <- outer(x, x,
"-"); - out[lower.tri(out)] }))
where A was a sample data frame
A <- data.frame(Group = rep(1:2,c(3,5)), Values = sample(1:8))
My goal is very similar, I wish to develop code to compute pairwise ratios
between elements of DISTINCT groups, yet I am struggling to adapt the code
for my needs. In particular, I have not been able to implement the
appropriate index to promote ratios among elements of different groups.
I would appreciate help on this subject.
Thanks,
Manolo
|