title: Nested loop through in R to give DF position when criteria is met
body: <p>I am running a nested for loop with an If-clause to determine which correlation in my matrix is above 90% (.9) or less than 100% (1). When running the loop I created it only gives the below output:</p>
  <p><a href="https://i.stack.imgur.com/SIIHe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SIIHe.png" alt="R issue" /></a></p>
  <p>Please see my code below:</p>
  <pre><code>colss = ncol(x)
  rowss = nrow(x)
  
  for (i in rowss){
   for (j in colss){
     if (x[i,j] &gt; .9 || x[i,j] &lt; 1){
      print(x[i,j])
    }
   }
  }   
  </code></pre>
  <p>Is there a way to get the position in the DF that has the values needed <strong>(&gt;.9 || &lt; 1)?</strong></p>
  <p>Example output:</p>
  <blockquote>
  <p>[12] .90</p>
  <p>[15] .92098</p>
  </blockquote>
  <p><em>Disclosure: I tried looking at others questions that were similar to mine but the answers didn't make total sense, so if you could please dumb it down I would appreciate it.</em></p>