title: prop.table outputs negative values
body: <p>I'm trying to calculate the probability distribution of a huge sample.</p>
  <p>I'm using <code>prop.table</code> function; it works as expected when I supply a toy data like <code>c(1,2,3)</code>, but when I try it on my database, it gives negative outputs half of the time.</p>
  <p>Why is that?</p>
  <p>Edit:</p>
  <p>Here is the code:</p>
  <pre><code>dInfo &lt;- d[, props :=  prop.table(Data, by=.(N, SimulationID, AgentID, Type, AC)]
  </code></pre>
  <p>Here a part of my data:</p>
  <pre><code>structure(list(Time = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), AgentID = c(1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), AC = c(&quot;a&quot;, 
  &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, 
  &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, 
  &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, 
  &quot;a&quot;, &quot;a&quot;, &quot;c&quot;, &quot;c&quot;, &quot;c&quot;, &quot;c&quot;, &quot;c&quot;, &quot;c&quot;, &quot;c&quot;, &quot;c&quot;), Layer = c(0L, 
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
  0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
  0L), Type = c(&quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, 
  &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, 
  &quot;w&quot;, &quot;w&quot;, &quot;b&quot;, &quot;b&quot;, &quot;b&quot;, &quot;b&quot;, &quot;b&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, 
  &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;b&quot;, &quot;b&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, &quot;w&quot;, 
  &quot;w&quot;), Data = c(-0.004488192, 0.035931263, 0.000238355, -0.05017679, 
  -0.038905628, 0.011275043, -0.002179068, -0.004003432, 0.016829431, 
  -0.023060411, -0.06022472, 0.08615596, 0.0013049663, 0.019211488, 
  0.010899153, 0.0023098313, 0.027939968, 0.04645505, 0.0007778046, 
  -0.040082328, 0.039822448, 0.037230257, 0.13616666, 0.024908375, 
  0.015247015, 0, 0, 0, 0, 0, -0.016074684, 0.040625643, 0.043461435, 
  -0.030649526, -0.02392821, 0.040948648, -0.02336491, 0.018872455, 
  -0.00966381, 0.053552378, 0, 0, -0.056943502, -0.018150102, 0.0296274, 
  -0.06308299, -0.036620624, 0.065056846, -0.02112275, 0.046921805
  ), N = c(40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 
  40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 
  40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 
  40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L, 40L
  ), SimulationID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L), props = c(9.91097107644817, 6.66241744000629, 
  9.97337994012272, 4.54102536134095, 6.21473028139476, 9.58510403938687, 
  9.95876866798959, 9.92372850444168, 9.1287428935349, 8.44652608868229, 
  3.21071775135845, 0.980489679221862, 9.96825081589951, 8.88708762327722, 
  9.61010295867649, 9.95694207591156, 7.8145448800769, 5.08116158863253, 
  9.97167162498901, 6.03681752692042, 6.07611942773214, 6.46746051762461, 
  0.0303718985404854, 8.21575628567643, 9.27469717542228, 9.97355701003582, 
  9.97355701003582, 9.97355701003582, 9.97355701003582, 9.97355701003582, 
  9.19986406711566, 5.95465874208366, 5.52706640720111, 7.43632548490794, 
  8.33957729555316, 5.90582919664192, 8.40929463364054, 8.92301866654129, 
  9.68669369035605, 4.07036192254373, 9.97355701003582, 9.97355701003582, 
  3.62058833244095, 8.99790347833101, 7.5808865889129, 2.87586905369961, 
  6.55909663072181, 2.65731021303268, 8.67555229815946, 5.01242514582731
  ), Info = c(9.7341790210304e-156, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 0.315970828703403, 0.315970828703403, 0.315970828703403, 
  0.315970828703403, 0.315970828703403, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 9.7341790210304e-156, 9.7341790210304e-156, 
  9.7341790210304e-156, 9.7341790210304e-156, 0.315970828703403, 
  0.315970828703403, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN)), row.names = c(NA, 
  -50L), class = c(&quot;data.table&quot;, &quot;data.frame&quot;), .internal.selfref = &lt;pointer: 0x55dc142f2a20&gt;)
  </code></pre>