R Circular package is calculating incorrect mean

I’m working with sea turtle hatchling orientation data and I’m calculating a mean direction for each nest however this appears to be giving me some incorrect values. Confusingly this isn’t an issue for all nests or not that I can tell at least.

I don’t know if this is to do with how the package calculates the means, how I’m subsetting the data by the nest tag from the main spreadsheet or that I’ve set the zero=pi/2 to correct the orientation of the plot.

Unfortunately I can’t post the dataset as it’s an on endangered species but any help is greatly appreciated, the turtles will appreciate it too.

What I’ve done:
I created an object ‘cdata’ as a subset of my main spreadsheet ‘circdata’ to just include the bearings as the package did’t like the non-numerical values in the main sheet. Then I plot the nest, calculate the circular mean direction for that nest and then plot the mean as the arrow.

cdata<- circular(circdata$Diff.360, type="directions", units="degrees", template="none",rotation = ("clock"),modulo = ("2pi") ,zero = pi/2)

plot(cdata [circdata$Nest.Tag == "A401"], cex=0.9, bin=180, stack=TRUE, sep=0.07, shrink=1.5)

df3mean<- mean.circular(cdata [circdata$Nest.Tag == "A401"], na.rm = TRUE) arrows.circular(df3mean,lwd = 3)

Here I subset the cdata mean for a nest tag from the circdata main dataset, I don’t think it would be but is this causing a problem?

[Here you can see a nest and each datapoint is a hatchlings direction, however the circular mean calculated by the package and displayed by the arrow isn’t anywhere actual datapoints.]

https://i.stack.imgur.com/A40At.png

  • 1

    I can replicate the issue with seq(270, 350, by = 10). Not sure why, but if I remove type = "directions", the problem goes away, even though ?circular states that this argument is not used. So try removing the type?

    – 

  • Yup this has fixed it straight away! Cheers for the help

    – 

Leave a Comment