[R] Suggestions for help & weighted.mean

Yan Wong h.y.wong at leeds.ac.uk
Fri Aug 11 17:01:43 CEST 2006


On 11 Aug 2006, at 12:49, Duncan Murdoch wrote:

> It makes sense in this case, but in the case where there is more  
> than one infinite weight, the result has to be NaN.
> ... it would be a lot more complicated if it were to handle this  
> very special case.

Yes - I see that it may not be worth slowing down the code to cope  
with this one particular case. I suppose it really comes down to a  
question of completeness versus speed.

> On the other hand, if you know that in your situation there is at  
> most one infinite weight, then you could use
>
> if (any(inf <- is.infinite(w))) x[inf]
> else weighted.mean(x, w)

Thanks. I think I do something like that already, but your code is  
cleaner than mine!

>> p.s. a while ago I suggested using '??xxx' as a shortcut for   
>> help.search("xxx"), much like '?xxx' is a shortcut for help 
>> ("xxx"). I  was just wondering if anyone had any more thoughts on  
>> the matter?
> Suggestions like this (and probably the one above) belong more in  
> the R-devel list than here.

OK. Thanks.

> I think your ?? suggestion is reasonable; why don't you write up  
> the necessary patch to implement it, and see if it's feasible?    
> Include that in your post to R-devel, and it will be easier for  
> others to see the pitfalls (if there are any).

Great. I'll do that when I have time (and if I can work out how the  
codebase works), then try posting it to R-devel.

Cheers

Yan



More information about the R-help mailing list