R - find a specific value in the matrix

Asked

Viewed 49 times

0

I’m having trouble finding a specific value in a matrix. The problem is that my matrix is too big to put here [360,181], so I’ll have to solve with an example.

x<- matrix(1:50, ncol=5)

I need something like:

x[x==14]

And he returns me:

[4,2]

Where respectively my value 14 is found in my row 4 and column 2.

Thank you!

  • 6

    which(x == 14, arr.ind = TRUE).

  • Thank you Rui Barradas!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.