[datatable-help] Fail to add new columns within a function

Matt Dowle mdowle at mdowle.plus.com
Tue Dec 17 20:11:20 CET 2013


On 15/12/13 23:26, Huashan Chen wrote:
> Hi Matthew,
>
> Thank you for the thoughtful reply. It's from a real example I am using
> where a master dataset is to be merged with other datasets by selected rows
> and columns(may or may not exist in master dataset). This function is call
> multiple times. As can see from the simple example, a master dataset is
> passed in by reference to avoid duplications.
>
> As you also pointed out, alloc.col(DT, some large value) outside the
> function can fix this problem. But I am wondering if the all.col() call
> within the function could be more preferable?
If the name of the master table doesn't change,  then you don't need to 
pass it in at all.   Just use it directly inside the function and then 
yes the alloc.col will work.   But if it's being merged with another 
dataset, then that merge will create a new table so I'm now confused 
again as the code didn't come through in this thread from nabble.

The question seems like a good one and would be best on Stack Overflow 
where we can see the code, edit and comment etc.
http://stackoverflow.com/questions/tagged/data.table 
<http://stackoverflow.com/questions/tagged/data.table?sort=active&pagesize=50>

Thanks, Matt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20131217/d2d6670f/attachment.html>


More information about the datatable-help mailing list