有没有办法可以在数据帧上自动执行几个which.max函数?

时间:2016-04-21 15:29:09

标签: r dataframe which

说我有一个数据框:

 DF <- data.frame(V1=c(2,8,1),V2=c(7,3,5),V3=c(9,6,4))
>DF
   V1 V2 V3
1  2  7  9
2  8  3  6
3  1  5  4

我知道您可以使用以下命令返回单个列的最高值的rowname:

which.max(DF[,1])

但是可以使用哪个匹配返回每列中最高值的rowname,而无需为数据框中的每个列手动输入which.max?

提前致谢。

1 个答案:

答案 0 :(得分:3)

使用循环

function post(){
 var options = {
     hostname: 'something.google.com',
     port: 443,
     path: '/',
     method: 'post'
 };

 var data = {.....}

 var req = https.request(options,(res)=>{
 ....
 ...
 });

 req.write(JSON.stringify(data));
 req.on('error',(e)=>{
    setTimeout(()=> {
       post();
    ​}, 50000);
  })
 req.end();
}