[R] plotting every ith data point?
K. Elo
maillists at nic.fi
Thu Feb 21 07:33:51 CET 2008
Hi,
this might also work for You:
> points(example.df$StartDate[ (row(example.df)%%5)==0 ],
example.df$DSR2[ (row(example.df)%%5)==0 ], type="p", pch=3)
> points(example.df$StartDate[ (row(example.df)%%5)==0 ],
example.df$DSR2[ (row(example.df)%%5)==0 ], type="p", pch=3)
Kind regads,
Kimmo
Jessi Brown wrote (21.02.2008):
> 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.
More information about the R-help
mailing list