Gagnon,Francois [SteFoy]
2007-Jul-17 18:43 UTC
[R] Missing value in circ.mean and polar.plot
Hi, I try to compute circular means for a matrix with NAs, but the function "circ.mean" return only means for lines with complete values and do not accept "na.omit=T" or "na.rm=T", or "na.action=na.omit", or "na.fail=T". Also, I try to use "polar.plot" of the package poltrix with the same matrix, but angles are not display because of many NAs. Does any one know how what should be the right NA action to get results in these two cases ? # Example of data set of theta in radians day measure strenght theta.1 theta.2 theta.3 theta.4 1 1 1 4.101523742 4.71238898 5.393067389 4.276056667 2 1 2 2.583087293 0 NA NA 3 1 1 3.385938749 3.769911184 4.380776423 NA 4 1 2 1.239183769 0.680678408 1.570796327 NA 5 1 4 3.508111797 3.682644722 5.113814708 NA 1 2 3 3.94444411 4.08407045 NA 3.804817769 2 2 2 3.543018382 NA NA NA 3 2 3 3.543018382 3.926990817 4.71238898 NA 4 2 1 1.413716694 1.448623279 1.570796327 NA 5 2 2 3.141592654 3.316125579 4.71238898 NA 1 3 3 3.874630939 4.555309348 NA 3.857177647 2 3 1 3.560471674 NA NA NA 3 3 3 3.769911184 3.926990817 4.36332313 NA 4 3 2 1.570796327 1.291543646 1.570796327 NA 5 3 1 3.054326191 3.228859116 4.956735076 NA #Circular mean day <- as.factor(day) library(CircStats) tapply(theta.1, day, circ.mean) tapply(theta.2, day, circ.mean) tapply(theta.3, day, circ.mean) tapply(theta.4, day, circ.mean) # polar plot par(mfrow=c(2,2)) library(plotrix) polar.plot(strenght, theta1, main="1") polar.plot(strenght, theta2, main="2") polar.plot(strenght, theta3), main="3") polar.plot(strenght, theta4, main="4") François Gagnon Biologiste, étudiant PFETE, Section Conservation des populations/ Biologist, FSWEP student, Populations conservation Division Service canadien de la faune/Canadian Wildlife Service Environnement Canada/Environment Canada 1141, route de l'Église B.P. 10100 Québec (Qc), G1V 4H5 CANADA Téléphone/Phone: (418) 648-4335 Courriel/Mail: francois.gagnon@ec.gc.ca [[alternative HTML version deleted]]
Gagnon,Francois [SteFoy] wrote:> Hi, > > I try to compute circular means for a matrix with NAs, but the function "circ.mean" return only means for lines with complete values and do not accept "na.omit=T" or "na.rm=T", or "na.action=na.omit", or "na.fail=T". > Also, I try to use "polar.plot" of the package poltrix with the same matrix, but angles are not display because of many NAs. > Does any one know how what should be the right NA action to get results in these two cases ? >Hi Francois, For one thing, you should be using radial.plot, as the angles are in radians, not degrees. However, your data shows up a couple of problems with radial.plot that I will fix. I'm currently fixing some minor (I hope) problems with plotrix v2.2-3 and this should turn up on CRAN in the next few days. I'll see if I can get radial.plot to produce the sort of plots you are seeking. Thanks for finding the problem. Jim