Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 value of every column and the maximum and minimum value of every row.

like image 728
Kostas Dimakis Avatar asked Nov 12 '14 17:11

Kostas Dimakis


1 Answers

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

like image 132
Kostas Dimakis Avatar answered Sep 28 '22 02:09

Kostas Dimakis