Dear R-Helpers,

I need the centroid of circular data and (because the function used does not provide the centroid coordinates, or did I miss sth.?) tried it via the indirect way and just computed the cartesian coordinates:

>>>
library(plotrix)
library(maps)

#generate data
data1<-matrix(c(1.8,1.5,1.2,0.9,0.0,-0.9,-0.6,0.3)+1.2,nrow=1)
#radial plot
radial.plot(data1,labels=paste("Dim",1:8,sep=""),rp.type="s",
main="test",show.grid=TRUE, radial.lim=c(0,3.5), show.centroid=TRUE, clockwise=T)
#compute cartesian coordinates
deg1<-seq(from=0,to=7,by=1)*pi/4
x=(data1)*cos(2*pi-deg1)
y=(data1)*sin(2*pi-deg1)
#print cartesian points (of polygon)
points(x,y,pch=18)
#print cartesian centroid
points(matrix(centroid.polygon(cbind(as.vector(x),as.vector(y))), nrow=1), pch=17)
>>>

My problem is, that the centroid computed by the radial.plot-function (big unfilled circle) is somewhat different from the one computed 'by hand' using cartesian coordiantes and centroid.polygon (small triangle). I would really appreciate any suggestions how to obtain the correct centroid and what is wrong here.

Thanks,
Stefan

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to