Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 按因子在数据表中迭代,并在另一个数据帧中插入结果_R_Data.table_R Factor - Fatal编程技术网

R 按因子在数据表中迭代,并在另一个数据帧中插入结果

R 按因子在数据表中迭代,并在另一个数据帧中插入结果,r,data.table,r-factor,R,Data.table,R Factor,我有下面的数据表 > 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.00000

我有下面的数据表

> 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
我想知道当字段优先、平台和CCR相等时,每个sched比其他sched好多少倍。并按sched将这些数字分组

首先,我创建组的所有组合,在其中进行比较

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

你如何定义“每一个sched都比其他sched好”?对不起,我没提到。sched的加速比越大越好。所以我必须把它们分为加速比大、加速比小或加速比相等的三类。这对我来说很不清楚。也许你可以添加可复制的输入和期望的输出?添加示例作为更新
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
d <- expand.grid(first=c("heat", "lu"),
                 sched=c("eft", "mcp"),
                 CCR=c(0.1, 1), platform=c(1,2))
d$speedup <- 1:16
res <- data.frame(first=c("eft", "mcp"),
                  win=c(0, 8), lose=c(8, 0), draw=c(0, 0),
                  second=c("mcp", "eft"))