title: Can someone explain the difference between the code snippets I've mentioned below?
body: <p>I've borrowed this code snippet from a website.</p>
  
  <pre><code>library(mlbench)
  data(BostonHousing)
  
  testing &lt;- scale(BostonHousing[, c("age", "nox")])
  set.seed(5)
  ## A random sample of 5 data points
  startSet &lt;- sample(1:dim(testing)[1], 5) 
  </code></pre>
  
  <p>I later modified the startset object with my own piece of code which is something like this:</p>
  
  <pre><code>set.seed(5)
  startSet&lt;- sample(1:nrow(testing)[1], 5)
  </code></pre>
  
  <p>When I ran both codes simultaneously, I got the same results. </p>
  
  <p>Can someone explain the difference between using dim and nrow. Even though both are different functions, why did they return the same value. </p>
  
  <p>Please help me as I am new to R and trying to learn. </p>
  
  <p>Thanks in advance. </p>