Search code examples
rmininfinity

How can I find the smallest value in a matrix that is greater than -Inf with R?


I have a matrix of values some of which are -Inf. How can I find the smallest value that is greater than -Inf?


Solution

  • This way:

    foo <- matrix(c(1,2,-Inf,3),nrow=2,ncol=2)
    min(foo[foo>-Inf])
    [1] 1