# Estimating the mean of angles (Assuncao, 1994), Ap - 26.07.2007. Translated to R on 19.09.2012. Updated on 13.02.2013 (R/C++ version). rm(list = ls()) # cppFile <- "/Users/afs80b/Dropbox/Rcpp/" cppFile <- "/Users/arnepommerening/Dropbox/Rcpp/" # cppFile <- "/Rcpp/" library(Rcpp) sourceCpp(paste(cppFile, "MeanOfAngles.cpp", sep = "")) # Implementation # Settings xFile <- paste(cppFile, "Clg6.txt", sep = "") xmax <- 98 ymax <- 107 # Load data sdata <- read.table(xFile, header = T) dim(sdata) names(sdata) length(sdata) pointList <- calcMeanOfAngles(sdata$x, sdata$y, xmax, ymax, 0.25, 7) mean(pointList$angle) pointList$weight <- 1 / length(pointList$angle) d <- density(pointList$angle, weights = pointList$weight, kernel = "epanechnikov", bw = 15, n = length(pointList$angle)) #, from = 0, to = 180) par(mar = c(2, 5, 1, 1)) # par(new = T) plot(d, xlab = "", ylab = "", main = "", las = 1, axes = FALSE, lwd = 2, col = "red", xlim = c(0, 210), ylim = c(0, 0.010)) # col = "blue", ylim = c(0, 2.0), xlim = c(0, 1), axis(side = 1, lwd = 2, las = 1, cex.axis = 1.7) axis(side = 2, lwd = 2, las = 1, cex.axis = 1.7) box(lwd = 2) max(pointList$angle) sum(pointList$weight)