From: Gabor Grothendieck <ggrothendieck_at_gmail.com>

Date: Sat 09 Jul 2005 - 02:24:26 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 09 02:47:34 2005

Date: Sat 09 Jul 2005 - 02:24:26 EST

To be fair none of Introduction to R, ?plot nor the reference card really cover this without substantial digging.

# test data

x <- 1:10

y <- x*x

plot(x[x > 5], y[x > 5])

# or

plot(y ~ x, subset = x > 5)

# We can have combine conditions like this:

plot(y ~ x, subset = x > 5 & y < 50)

# also if your intention was really set the plot limits rather than # condition on the data then you can use xlim= and ylim=, e.g.

plot(y ~ x, xlim = c(5, max(x)))

Read over all of these: ?plot, ?plot.formula, ?plot.default, ?"&", ?">", ?c, ?max noting that plot dispatches plot.formula if you specify a formula in plot and that subset= is an argument to the latter.

On 7/8/05, Berton Gunter <gunter.berton@gene.com> wrote:

> Please first read "An Introduction to R" (one of the pdf manuals that ships

*> with R) before posting these sorts of questions, as it is written
**> specifically to help you get started (I think fairly clearly).
**>
**> Other (links to) learning resources may be found on the CRAN website. Please
**> take advantage of them. One that you may find particularly helpful is:
**>
**> Newbies (and others!) may find useful the R Reference Card made available by
**> Tom Short and Rpad at http://www.rpad.org/Rpad/Rpad-refcard.pdf or through
**> the "Contributed" link on CRAN (where some other reference cards are also
**> linked). It categorizes and organizes a bunch of R's basic, most used
**> functions so that they can be easily found. For example, paste() is under
**> the "Strings" heading and expand.grid() is under "Data Creation." For
**> newbies struggling to find the right R function as well as veterans who
**> can't quite remember the function name, it's very handy.
**>
**> Yes, the initial learning curve is steep. However, if you do any serious
**> data analysis and/or plotting, I promise that you will find it well worth
**> your while.
**>
**> -- Bert Gunter
**> Genentech Non-Clinical Statistics
**> South San Francisco, CA
**>
**> "The business of the statistician is to catalyze the scientific learning
**> process." - George E. P. Box
**>
**>
**>
**> > -----Original Message-----
**> > From: r-help-bounces@stat.math.ethz.ch
**> > [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Michael Hopkins
**> > Sent: Friday, July 08, 2005 8:50 AM
**> > To: r-help@stat.math.ethz.ch
**> > Subject: [R] Plotting a simple subset
**> >
**> >
**> >
**> > Hi all
**> >
**> > Just converting from Stata to R and struggling a little to
**> > come to terms
**> > with the new philosophy/command line.
**> >
**> > E.g. I want to plot x against y if x < 5
**> >
**> > In Stata: graph x y, if( x < 5 )
**> >
**> > How do I do this in R? Have tried most of the obvious options without
**> > success.
**> >
**> > Can I have multiple subsets? I.e. In Stata: if( x < 5 && y > 3 )
**> >
**> > TIA
**> >
**> > Michael
**> >
**> >
**> > _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
**> > _/_/_/_/_/_/_/
**> >
**> > _/ _/ _/_/_/ Hopkins Research Ltd
**> > _/ _/ _/ _/
**> > _/_/_/_/ _/_/_/ http://www.hopkins-research.com/
**> > _/ _/ _/ _/
**> > _/ _/ _/ _/ 'touch the future'
**> >
**> > _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
**> > _/_/_/_/_/_/_/
**> >
**> > ______________________________________________
**> > R-help@stat.math.ethz.ch mailing list
**> > https://stat.ethz.ch/mailman/listinfo/r-help
**> > PLEASE do read the posting guide!
**> > http://www.R-project.org/posting-guide.html
**> >
**>
**> ______________________________________________
**> R-help@stat.math.ethz.ch mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
*

>

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 09 02:47:34 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:33:26 EST
*