[R] Binned line plot

Joshua Wiley jwiley.psych at gmail.com
Tue Nov 22 07:08:35 CET 2011

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.  Once you have a variable indicating the bins.  You could
center the bins at the mean, median, or ... for each set of points
using ?ave.



On Mon, Nov 21, 2011 at 9:29 PM, Jeffrey Joh <johjeffrey at hotmail.com> wrote:
> I have a scatter plot with 10000 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 10000 points, I would also like to bin the data and make boxplots at certain intervals, so that I have a set of boxplots to represent each bin.  I would also like the width of each box to be proportional to the number of points in each bin.
> How can I make these plots?  Is there a simple package to use?
> Jeffrey
> ______________________________________________
> R-help at 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.

Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, ATS Statistical Consulting Group
University of California, Los Angeles

More information about the R-help mailing list