From: Greg Snow <Greg.Snow_at_imail.org>

Date: Fri, 22 Feb 2008 12:37:54 -0700

Date: Fri, 22 Feb 2008 12:37:54 -0700

Just to give you more options to choose from,

Here is a variation on Gabor's solution:

with(example.df[c(TRUE,FALSE,FALSE,FALSE,FALSE),], { plot(DSR1 ~ StartDate, type = "b", ylim = c(0.3, 0.9)) points(DSR2 ~ StartDate, type = "b", pch = 3) })

Move the TRUE around and you get the different sequences and you don't need to know the number of rows.

On a similar note you could try:

plot(DSR1 ~ StartDate, type='b', ylim=c(0.3,0.9), pch=c(1,rep(NA,4))) points(DSR2 ~ StartDate, type='b', pch=c(3,rep(NA,4)))

You will still have the lines between all the points, but only every 5th point.

Hope this helps,

-- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow_at_imail.org (801) 408-8111Received on Fri 22 Feb 2008 - 19:41:04 GMT

> -----Original Message-----

> From: r-help-bounces_at_r-project.org> [mailto:r-help-bounces_at_r-project.org] On Behalf Of Jessi Brown> Sent: Wednesday, February 20, 2008 6:57 PM> To: Gabor Grothendieck> Cc: r-help_at_r-project.org> Subject: Re: [R] plotting every ith data point?>> Thanks for the ideas so far, Gabor and Phil.>> I was hoping to find a solution that didn't depend on> building another data frame, but if that's the easiest way, I> can certainly do it through that route. At least your> solutions involve fewer lines of code than I had devised for> extracting the desired rows (am still a newbie at data> manipulation with R!).>> cheers, Jessi>> On Wed, Feb 20, 2008 at 7:08 PM, Gabor Grothendieck> <ggrothendieck_at_gmail.com> wrote:> > Try this:> >> > ix <- seq(1, nrow(example.df), 5)> > with(example.df[ix,], {> > plot(DSR1 ~ StartDate, type = "b", ylim = c(0.3, 0.9))> > points(DSR2 ~ StartDate, type = "b", pch = 3)> > })> >> >> >> >> > On Wed, Feb 20, 2008 at 6:57 PM, Jessi Brown> <jessilbrown_at_gmail.com> wrote:> > > Hello, fellow R enthusiasts.> > >> > > Ok, I've been racking my brain about this small issue,> and between> > > searching the help archives and reading through the> plot-related >> > documentation, I can't figure out how to achieve my desired> endpoint> > > without some ugly, brute force coding.> > >> > > What I would like to do is make a plot in which only a> subset of my> > > data are plotted, but in regular intervals, such as every> 5th point> > > along the sequence. Is anyone aware of a built-in> function in plot> > or > a related graphing family that can do this, or> alternatively, a> > simple > way to extract the desired rows from my original> dataframe?> > I want to > do this because I want to plot multiple series> of points> > with their > confidence intervals (arrows), and even if I specify> > type="b," the > output ends up looking like just a series> of crowded points.> > >> > > For example, if you try making the plot below, you will> see how >> > crowded two lines look without error bars:> > >> > > > example.df<-data.frame(StartDate=(94:157), DSR1=seq(0.4, 0.8,> > length.out=64), DSR2=seq(0.3, 0.9, length.out=64)) > >> > plot(example.df$StartDate, example.df$DSR1, type="b",> ylim=c(0.3,0.9))> > > > points(example.df$StartDate, example.df$DSR2, type="b",> pch=3) >> > > Any ideas for an elegant solution to my dilemma?> > >> > > Thanks in advance for any help.> > >> > > cheers, Jessi Brown> > >> > > Ph.D. student> > > Program in Ecology, Evolution, and Conservation Biology >> > University of Nevada, Reno > >> > ______________________________________________> > > 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.> > >> >>> ______________________________________________> 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.>

______________________________________________ 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.

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Fri 22 Feb 2008 - 20:30:16 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*