<div>Thanks for correction! </div><br><div class="gmail_quote">2011/11/7 Matthew Dowle <span dir="ltr"><<a href="mailto:mdowle@mdowle.plus.com">mdowle@mdowle.plus.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Mon, 2011-11-07 at 10:47 -0600, Branson Owen wrote:<br>
><br>
><br>
> On Fri, Nov 4, 2011 at 9:15 AM, Chris Neff <<a href="mailto:caneff@gmail.com">caneff@gmail.com</a>><br>
> wrote:<br>
> > I'd rather have the print.data.table function override the<br>
> > print.data.frame one. How can I do this?<br>
><br>
> Try:<br>
><br>
> print.data.frame <- data.table:::print.data.table<br>
><br>
><br>
> Does it create a copy of 'print.data.frame' in global environment?<br>
<br>
</div>A copy of print.data.table, yes. It might be a copy-on-write, not sure.<br>
<div class="im"><br>
> > base:::print.data.frame <- data.table:::print.data.table<br>
<br>
</div>That doesn't work, does it?<br></blockquote><div><br></div><div>Oops, no. Shouldn't post my 'guess' before I even try it by myself. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
> If print.data.frame is always called in global environment, I guess I<br>
> worried too much.<br>
<br>
</div>Are you thinking about speed here? .GlobalEnv is always pos 1 on<br>
search() so those functions are found quickest. base is last on search()<br>
so they're actually slower if repeated many times in a loop, due to<br>
searching() for them. I think compile()'d code might save the location<br>
in the byte code, to save the searching()ing, not sure.<br>
<br></blockquote><div><br></div><div>Interesting! I posted that problematic suggestion is because it worked for me in other case before. I was trying to overwrite data.table's default argument: 'nomatch' = 0 instead of NA. I can't find a smart way to do it, and I end up with overwrite whole data.table function. At that time, data.table.fn <- function() {...} is not enough. I found that I need to add scope operator ::: to overwrite internal function. </div>
<div><br></div><div>Thanks again for the correction! </div></div>