[R] Range of circular data
Waichler, Scott R
Scott.Waichler at pnl.gov
Tue Jan 8 02:05:17 CET 2008
I want to get the minimum arc (in degrees) needed to include a set of
compass directions. I would like to use the range.circular() function
of the package circular, because that package understands a compass-type
of angle convention, but it gives results I don't understand. Howver, I
can get the correct answer in the example below, 90 degrees, using the
CircStats package. How can I make the circular package work for me?
> R.version.string
[1] "R version 2.6.1 (2007-11-26)"
> library(circular)
> y <- circular(c(45, 135), units = "degrees", template = "geographics")
> range.circular(y)
Circular Data:
Type = angles
Units = degrees
Template = geographics
Modulo = asis
Zero = 1.570796
Rotation = clock
[1] 0
Just in case range.circular() expects radians, I tried this:
> range.circular(rad(y))
Circular Data:
Type = angles
Units = degrees
Template = geographics
Modulo = asis
Zero = 1.570796
Rotation = clock
[1] 88.4292
I can get the correct answer using CircStats instead:
> library(CircStats)
> y <- rad(c(45, 135))
> 180*circ.range(y)/pi
range
1 90
Thanks,
Scott Waichler
Pacific Northwest National Laboratory
scott.waichler _at_ pnl.gov
More information about the R-help
mailing list