<div>
Hi all,
</div><div><br></div><div>Here's a behaviour of `rbindlist` that I came across that I think is undesirable. If the columns to be "rbind" are of type "integer" and "numeric", then, the class "integer" is retained which results in different results than intended.</div><div><br></div><div>require(data.table)</div><div>DT1 <- data.table(x = 1:5, y = 1:5)</div><div><div> x y</div><div>1: 1 1</div><div>2: 2 2</div><div>3: 3 3</div><div>4: 4 4</div><div>5: 5 5</div></div><div><br></div><div>DT2 <- data.table(x = 6:10, y = 1:5/10)</div><div><div> x y</div><div>1: 6 0.1</div><div>2: 7 0.2</div><div>3: 8 0.3</div><div>4: 9 0.4</div><div>5: 10 0.5</div></div><div><br></div><div>sapply(DT1, class)</div><div><div> x y </div><div>"integer" "integer" </div></div><div><br></div><div>sapply(DT2, class)</div><div><div> x y </div><div>"integer" "numeric" </div></div><div><br></div><div>rbindlist(list(DT1, DT2))</div>
<div><div><div> x y</div><div> 1: 1 1</div><div> 2: 2 2</div><div> 3: 3 3</div><div> 4: 4 4</div><div> 5: 5 5</div><div> 6: 6 0 <~~~~ from here, the result should be 0.1 to 0.5 for the next 5 rows or y.</div><div> 7: 7 0</div><div> 8: 8 0</div><div> 9: 9 0</div><div>10: 10 0</div></div><div><br></div><div>Is this behaviour unexpected or we've to manually take care of this? Seems more proper to be taken care of internally to me though.</div><div><br></div><div>Best,</div><div>Arun.</div><div><br></div></div>