所以我这张表的结果如下:
V2 V3 V4 V5 V6 V7
1 14.06863 11.50424 333173.1 0.0 0.00000
2 14.50265 11.89501 387709.7 54536.6 0.43402 125654.58
3 14.55234 11.95746 402124.0 14414.3 0.04969 290084.52
4 14.78606 12.14149 453059.3 50935.3 0.23372 217933.00
5 15.16970 12.51004 496142.1 43082.8 0.38364 112300.07
6 14.41104 11.81296 539661.3 43519.2 -0.75866 -57363.25
7 14.86976 12.23968 603475.4 63814.1 0.45872 139113.40
数据框称为d,我需要的是添加一个名为Best的新列,并在具有负V6和正V5的行中添加'best'
如何添加此行? 谢谢!
答案 0 :(得分:0)
添加Best
列:
d$Best <- ""
d$Best[which(with(d, Delta_Cost>0 & Delta_LY<0))] <- "best"