title: How can I determine digits of precision in R?
body: <p>I am building a time course dataframe. The time information is in seconds and created using <code>seq(start, end, 0.001)</code> and the start and end time points are based on values from a csv file.</p>
  <p>Start and end time points are sometimes of the form &quot;578.1799999999999&quot; but sometimes the equivalent will be &quot;578.180&quot; or &quot;578.18000000000001&quot;. This creates problems down the line when I'm trying to merge several time courses, since for R these are all different time points. Here a comparison from two time courses where each row should represent the same time point, however, some of them are different for R (<code>df$test = df$t1 == df$t2</code>):</p>
  <p><a href="https://i.stack.imgur.com/d9gyb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d9gyb.png" alt="enter image description here" /></a></p>
  <p>To solve this problem, I tried to round all start and end time points to a precision of 3 digits, corresponding to ms, however, this is not working:</p>
  <pre><code>&gt; round(578.1799999999999,3)
  [1] 578.1799999999999
  </code></pre>
  <p>Does anyone have an idea how I can &quot;force&quot; R to round to 3 digits and forget the rest?</p>