Find the maximum and minimum value of every column and then find the maximum and minimum value of every row

前端 未结 4 786
离开以前
离开以前 2020-12-13 19:04

I\'ve got this matrix:

a <- matrix(rnorm(1000 * 18, mean = 100, sd = sqrt(10)), 1000, 18)

I would like to find the maximum and minimum v

4条回答
  •  盖世英雄少女心
    2020-12-13 19:31

    Figured it out.

    Minimum and maximum of every column:

    apply(a,2,min)
    apply(a,2,max)
    

    Minimum and maximum of every row:

    apply(a,1,min)
    apply(a,1,max)
    

    Found the information here http://www.personality-project.org/r/r.commands.html

提交回复
热议问题