title: r syntax: purpose of `[1]`
body: <p>I found this code on :<a href="http://onertipaday.blogspot.co.il/search/label/descriptive%20statistic" rel="nofollow noreferrer">http://onertipaday.blogspot.co.il/search/label/descriptive%20statistic</a>
  The code is describing a workaround for finding the <code>min</code> and <code>max</code> in a dataset that has <code>inf</code> and <code>-inf</code> in a vector. However I don't understand the purpose of the <code>[1]</code> and <code>[2]</code> in the last two lines of code.</p>
  
  <pre><code>data &lt;- c(-Inf, 1,2,3,4,5,6,7,8,9,10, Inf)
  max(data)
  # Return Inf
  min(data)
  # Return -Inf
  # To solve the problem I went to:
  range(data, finite=TRUE)
  # Then you can do
  myMinimum &lt;- range(data, finite=TRUE)[1]
  myMaximum &lt;- range(data, finite=TRUE)[2]
  </code></pre>