Sarah Moens
2009-Sep-10 13:07 UTC
[R] Listing all data instead of only k-elements when using combn-function
Hi dear reader,
I've been searching the help-archive and found many topics with regard to
the use of combinations, but I can't seem to make sense out of the advice
given. So I posted my question here, my apologies that this has come up for
many times before.
Example data-set:
Group Scores
A 5
A 10
A 9
B 2
B 3
I have 5 subjects. Those subjects are each assigned to a particular group,
group A or group B. Each subject gets a score on a test (dependant
variable).
Now instead of just getting the mean of group A and group B of the sample
I've drawn, I want to list all possible combinations (in this case 10
combinations, to eventually be able to compute for each combination, the
mean of group A and group B.
That is:
Group [,1] [,2] .
[,10]
A 5 5
9
A 10 10
2
A 9 2
3
B 2 9
5
B 3 3
10
combn does provide me with 10 possible combinations, but it only lists a
part of the data:
[,1] [,2] [,3] [,4] [,5]
[,6] [,7] [,8] [,9] [,10]
[1,] 5 5 5 5 5
5 10 10 10 9
[2,] 10 10 10 9 9
2 9 9 2 2
[3,] 9 2 3 2 3
3 2 3 3 3
Thanks a lot!!
Sarah
[[alternative HTML version deleted]]