Re: [R] Plotting a simple subset

From: Peter Wolf <s-plus_at_wiwi.uni-bielefeld.de>
Date: Sat 09 Jul 2005 - 02:24:41 EST

Michael Hopkins wrote:

>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 )
>

Try:

x<-rnorm(20,0,5)
y<-2*x+rnorm(20)
# plot without condition
plot(x,y)
# some conditions on x and y
index<- x<5 & y>3
plot(x[index],y[index])

Peter Wolf

>
>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 Received on Sat Jul 09 02:45:38 2005

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