Bkk
Bkk

Reputation: 177

How to find the max value of a specific column in a matrix

I am new to R. Many thanks in advance for your help.

I am trying to find the maximum value of a single (the first) column in a matrix, "bin.matrix". Of course, I have been able to find the max value for all columns using:

apply(bin.matrix, 2, max)

But I can't seem to figure out how to get the value for just the first column. It's a homework question, so just reading the first value won't do unfortunately. The next question asks for the max value in all but the first column.

Thanks again for your help.

Upvotes: 2

Views: 603

Answers (1)

akrun
akrun

Reputation: 887118

We can select the first column by subsetting with numeric index and get the max

max(bin.matrix[,1])

Upvotes: 1

Related Questions