fastest way to get Min from every column in a matrix?

前端 未结 6 2087
执念已碎
执念已碎 2020-12-16 16:13

What is the fastest way to extract the min from each column in a matrix?


EDIT:

Moved all the benchmarks to the answer below.

Using

6条回答
  •  心在旅途
    2020-12-16 16:56

    lapply( split(mat, rep(1:dim(mat)[1], each=dim(mat)[2])), min)
    
    which( ! apply(my.mat, 2, min, na.rm=T) ==
            sapply( split(my.mat, rep(1:dim(my.mat)[1], each=dim(my.mat)[2])), min) )
    # named integer(0)
    

提交回复
热议问题