[R] Binned line plot

2011-11-21 Thread Jeffrey Joh
I have a scatter plot with 1 points.  I would like to add a line that bins every 50 points and connects the average of each bin.  I'm looking for something similar to line type m in Stata. With this dataset of 1 points, I would also like to bin the data and make boxplots at certain

Re: [R] Binned line plot

2011-11-21 Thread David Winsemius
On Nov 22, 2011, at 12:29 AM, Jeffrey Joh wrote: I have a scatter plot with 1 points. So you have numeric x and y values. I would like to add a line that bins every 50 points and connects the average of each bin. What is the rule to be applied to form these bins? You may want to

Re: [R] Binned line plot

2011-11-21 Thread Joshua Wiley
Hi Jeffrey, See ?factor ?rep and ?cut basically you just need to create another variable that indicates what bin a point belongs to, and then you just do regular plots. If you want to mix the scatterplot and the binned points, you'll need to make sure the bins fall somehwere in the same space.

Re: [R] Binned line plot

2011-11-21 Thread Bert Gunter
A fast way to get **only** means of successive bins of width k of a vector z of length nk is: m - colMeans(matrix(z,nrow = k)) (you wanted k =50) This was instantaneous for a length 1e6 numeric vector on my laptop. However, for anything else, you have to use something like cut() as others have

Re: [R] Binned line plot

2011-11-21 Thread Jim Lemon
On 11/22/2011 04:29 PM, Jeffrey Joh wrote: I have a scatter plot with 1 points. I would like to add a line that bins every 50 points and connects the average of each bin. I'm looking for something similar to line type m in Stata. With this dataset of 1 points, I would also like to