On Wed, 20 Aug 2003 19:37:59 +0100, Martin Biuw
<[EMAIL PROTECTED]> wrote :

>Hello,
>Is there a simple way to modify the circ.mean function in the CircStats 
>package to include a vector of weights to obtain a weighted average angle?

This should do it:

circ.weighted.mean <- function (x,w) 
{
    sinr <- sum(w*sin(x))
    cosr <- sum(w*cos(x))
    circmean <- atan(sinr, cosr)
    circmean
}

I was surprised that atan worked with 2 arguments; it's documented to
use only 1.  According to the docs, you're supposed to use atan2 if
you want the two argument arctangent.

Duncan Murdoch

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to