I've managed to get the code to proceed correctly by replacing the "myDT[, newCol := oldCol]" with:<br><br> tmpCol = myDT$oldCol<br> myDT$newCol = tmpCol<br><br>This has avoided the issue. Forgive me if I am using datatable incorrectly or abusing it, but this seems to do the trick for now, and I had several other questions that arose from all of this inspection.<br>
<br>1. As instructed in an earlier post, to a different user, I tried "gcinfo(TRUE)" and "options(datatable.verbose=TRUE)". The former didn't given any information that could be helpful, but the latter was quite interesting. I noticed that the following messages occurred frequently:<br>
<br> - setkey changed the type of column 'i' from numeric to integer, no fractional data present.<br> - First column i failed radixorder1, reverting to regularorder1<br> - setkey incurred a copy of the whole table, due to the coercion(s) above.<br>
- Non-first column 2 failed radixorder1, reverting to regularorder1<br><br>1A: Would I benefit from changing the types to integers pre-emptively, so that setkey doesn't have to do these coercions? (See Q 2 - how do I do that?)<br>
1B: Why is the whole table copied if one column is coerced? That may get to be problematic for larger tables, or multiple copies (due to multiple keys that are not yet coerced to integers).<br>1C: What can I make of the 'failed radixorder1' messages?<br>
<br>2: My data table objects are created from several different sources, and several have matching columns. However, the types are different in the different objects - some are numeric, some integer. Integer is a perfectly fine universal type for these particular columns. However, it seems that data.table only makes this coercion when "setkey()" is executed, rather than at the creation of the datatables. How can I make this coercion? Solely via DT[, selCol := as.integer(selCol)] ? This would seem to speed up all of that coercion & copying.<br>
<br>3: In the datatable vignette, p. 12 (at least in my version), there is a statement that NA is type logical in R. I don't know if this is causing issues, but that's not true. NA as logical is the default (I think), but one can have an NA in a numeric - e.g. `x <- c(pi, NA); str(x)`. <br>
3A: I have numeric NAs in my data tables - could this be related to issues observed (i.e. type complaints and segfaults)? <br> 3B: Some columns are entirely (numeric) NA in some of the data tables. Is this setting me up for heartache? :) These are combined with other datatables via rbind and merge.<br>
<br>Thanks!<br>