[R] Problem with circular::plot.circular()
require(circular) c - circular(rep(0, 20), zero = pi/2, rotation = 'clock') plot(c, stack = TRUE, shrink = 1.5) Can anyone tell me why the stack is offset from 0? _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ [[alternative HTML version deleted]] __ 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.
Re: [R] Problem with circular::plot.circular()
On 29/03/2009 7:39 AM, Michael Kubovy wrote: require(circular) c - circular(rep(0, 20), zero = pi/2, rotation = 'clock') plot(c, stack = TRUE, shrink = 1.5) Can anyone tell me why the stack is offset from 0? It's a histogram, and the bin starts at zero, and runs to pi/10 (I'm guessing, since it appears to choose 20 bins). You can see the binning effect if you set your data to c - circular(runif(20, 0, 2*pi), zero=pi/2, rotation='clock') Set bins to 1 and the offset will be undetectable: plot(c, stack = TRUE, shrink = 1.5, bins=1) Duncan Murdoch __ 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.
Re: [R] Problem with circular::plot.circular()
On 29/03/2009 9:23 AM, Michael Kubovy wrote: Thanks so much. I have another question: why the difference here: require(circular) c1 - circular(pi/2 + .0, zero = pi/2, rotation = 'clock') c2 - circular(pi/2 + .1, zero = pi/2, rotation = 'clock') opar - par(mfrow = c(1, 2)) plot(c1, stack = TRUE, bins = 1, main = expression(pi/2)) plot(c2, stack = TRUE, bins = 1, main = expression(pi/2 + .1)) par(opar) I don't see any points in the first plot, but the second one looks as I'd expect. Looks like a bug to me. I've cc'd the maintainer. In the PointsCircularRad function, this code does the counting: for (i in 1:bins) { bins.count[i] - sum(x = i * arc x (i - 1) * arc) } At this point x has been transformed to a vector of zeros, arc is the size of a bin in radians. But the expression above misses exact zeros, since it assumes x is positive. A simple fix is to add a line after saying bins.count[bins] - bins.count[bins] + sum(x = 0) Duncan Murdoch On Mar 29, 2009, at 8:09 AM, Duncan Murdoch wrote: On 29/03/2009 7:39 AM, Michael Kubovy wrote: require(circular) c - circular(rep(0, 20), zero = pi/2, rotation = 'clock') plot(c, stack = TRUE, shrink = 1.5) Can anyone tell me why the stack is offset from 0? It's a histogram, and the bin starts at zero, and runs to pi/10 (I'm guessing, since it appears to choose 20 bins). You can see the binning effect if you set your data to c - circular(runif(20, 0, 2*pi), zero=pi/2, rotation='clock') Set bins to 1 and the offset will be undetectable: plot(c, stack = TRUE, shrink = 1.5, bins=1) Duncan Murdoch __ 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.
Re: [R] Problem with circular::plot.circular()
Thanks so much. I have another question: why the difference here: require(circular) c1 - circular(pi/2 + .0, zero = pi/2, rotation = 'clock') c2 - circular(pi/2 + .1, zero = pi/2, rotation = 'clock') opar - par(mfrow = c(1, 2)) plot(c1, stack = TRUE, bins = 1, main = expression(pi/2)) plot(c2, stack = TRUE, bins = 1, main = expression(pi/2 + .1)) par(opar) On Mar 29, 2009, at 8:09 AM, Duncan Murdoch wrote: On 29/03/2009 7:39 AM, Michael Kubovy wrote: require(circular) c - circular(rep(0, 20), zero = pi/2, rotation = 'clock') plot(c, stack = TRUE, shrink = 1.5) Can anyone tell me why the stack is offset from 0? It's a histogram, and the bin starts at zero, and runs to pi/10 (I'm guessing, since it appears to choose 20 bins). You can see the binning effect if you set your data to c - circular(runif(20, 0, 2*pi), zero=pi/2, rotation='clock') Set bins to 1 and the offset will be undetectable: plot(c, stack = TRUE, shrink = 1.5, bins=1) Duncan Murdoch __ 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.
Re: [R] Problem with circular::plot.circular()
On 29/03/2009 9:58 AM, Duncan Murdoch wrote: On 29/03/2009 9:23 AM, Michael Kubovy wrote: Thanks so much. I have another question: why the difference here: require(circular) c1 - circular(pi/2 + .0, zero = pi/2, rotation = 'clock') c2 - circular(pi/2 + .1, zero = pi/2, rotation = 'clock') opar - par(mfrow = c(1, 2)) plot(c1, stack = TRUE, bins = 1, main = expression(pi/2)) plot(c2, stack = TRUE, bins = 1, main = expression(pi/2 + .1)) par(opar) I don't see any points in the first plot, but the second one looks as I'd expect. Looks like a bug to me. I've cc'd the maintainer. In the PointsCircularRad function, this code does the counting: for (i in 1:bins) { bins.count[i] - sum(x = i * arc x (i - 1) * arc) } At this point x has been transformed to a vector of zeros, arc is the Oops, that describes a test case slightly different than yours. With your data, x is a single zero. Duncan Murdoch size of a bin in radians. But the expression above misses exact zeros, since it assumes x is positive. A simple fix is to add a line after saying bins.count[bins] - bins.count[bins] + sum(x = 0) Duncan Murdoch On Mar 29, 2009, at 8:09 AM, Duncan Murdoch wrote: On 29/03/2009 7:39 AM, Michael Kubovy wrote: require(circular) c - circular(rep(0, 20), zero = pi/2, rotation = 'clock') plot(c, stack = TRUE, shrink = 1.5) Can anyone tell me why the stack is offset from 0? It's a histogram, and the bin starts at zero, and runs to pi/10 (I'm guessing, since it appears to choose 20 bins). You can see the binning effect if you set your data to c - circular(runif(20, 0, 2*pi), zero=pi/2, rotation='clock') Set bins to 1 and the offset will be undetectable: plot(c, stack = TRUE, shrink = 1.5, bins=1) Duncan Murdoch __ 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. __ 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.