0

I have following data table

> total.dt[,list(first, sched, platform, CCR, speedup)]
   first        sched platform  CCR   speedup
1:  mult static_hlfet        1  0.1  1.000000
2:  mult   static_mcp        1  0.1  1.000000
3:  mult   static_eft        1  0.1  1.000000
4:  mult static_lheft        1  0.1  1.000000
5:  mult       greedy        1  0.1  1.000000
---                                           
1634: gen64   static_eft       64 10.0  9.916995
1635: gen64 static_lheft       64 10.0  8.926877
1636: gen64       greedy       64 10.0  5.235970
1637: gen64    Horizon-8       64 10.0 11.523087
1638: gen64    Horizon-1       64 10.0  9.896009

I want to find out how many times every sched is better than every other sched, when fields first, platform and CCR are equal. And group these numbers by sched.

First I create all combinations of groups where I do the comparison.

setkey(total.dt, first, platform, CCR)
comb <- unique(total.dt[,list(first, platform, CCR)])

Now I can get a group where i can do the comparison

d <- total.dt[comb[n,], list(first, platform, CCR, sched, speedup)]

> print (d) # if n equals 1  
   first platform CCR        sched speedup
1:  mult        1 0.1 static_hlfet       1
2:  mult        1 0.1   static_mcp       1
3:  mult        1 0.1   static_eft       1
4:  mult        1 0.1 static_lheft       1
5:  mult        1 0.1       greedy       1
6:  mult        1 0.1    Horizon-8       1
7:  mult        1 0.1    Horizon-1       1

And now I have to count how many times every sched wins others (has bigger speedup), loses or has draw. This I have to store to the data frame which has 5 columns: (first, second, win, lose, draw). I have to repeat this operation for every row in comb and accumulate numbers in second dataframe.

And here I'm a bit lost, because I do not understand how to do this and how to store the result.

I'll appreciate any your help and sorry if this kind of question is not appropriate for SO.

UPD.

Minimal example.

I have following data:

d <- expand.grid(first=c("heat", "lu"),
                 sched=c("eft", "mcp"),
                 CCR=c(0.1, 1), platform=c(1,2))
d$speedup <- 1:16

I want get following results:

res <- data.frame(first=c("eft", "mcp"),
                  win=c(0, 8), lose=c(8, 0), draw=c(0, 0),
                  second=c("mcp", "eft"))

How do I calculate. First I take rows where first="heat", platform="1", CCR=".1". There are two such rows. First has sched=eft, speedup=1. The second one has sched=mcp, speedup=9. This means mcp wins. In the data.frame res we increase win counter in the row where first=mcp, second=eft. And we increase lose counter in the row where first=eft, second=mcp

Then I take next rows one by one from data frame d and repeat the procedure, filling the res data frame

mcsim
  • 1,647
  • 2
  • 16
  • 35
  • 1
    how do you define "every sched is better than every other sched" ? – Colonel Beauvel May 12 '15 at 13:40
  • Sorry, didn't mention that. sched is better if it has bigger speedup. So I have to categorize them into those, which have bigger speedup, smaller speedup or equal speedup – mcsim May 12 '15 at 15:38
  • This is pretty unclear to me. Maybe you could add reproducible input and desired output? http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Frank May 12 '15 at 15:44
  • Added the example as an update – mcsim May 12 '15 at 16:19

0 Answers0