[R] Plot using different symbols depending on value.

Petr Pikal petr.pikal at precheza.cz
Tue Jan 21 14:13:03 CET 2003


Hi

On 21 Jan 2003 at 13:46, Roger Bivand wrote:

> On Tue, 21 Jan 2003, Morten Sickel wrote:
> 
> > I am making a plot from R indicating an average, min and max value
> > for a number of sample types. as horizontal lines with the sample
> > types on the y-axis. (see http://home.newmedia.no/sickel/R.html for
> > the plot and code) In some cases, the min value is the detection
> > limit, and I would like to indicate that bu using a <, rather than
> > the usual | I use for indicating the value. I am plotting each of
> > the values using:
> > 
> >   points(low[s],s+offset,col=i/3,pch='I')
> > 
> > Is it some kind of inline if, iif(cond,true,false), function in R? I
> > have looked for it but not found it.
> 
> Maybe ifelse(test, yes, no), for a value of the same shape as test?
> 
> pch=ifelse(test, "I", "<") should work for points, I think.

or you can use vectorised input for pch like

x<-rnorm(10)
psymb<-c("I","<")
plot(1:10,x,type="n")
points(1:10,x,pch=psymb[(x<0)+1])


> 
> > 
> > Regards
> > 
> > Morten
> 
> -- 
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School
> of Economics and Business Administration, Breiviksveien 40, N-5045
> Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail:
> Roger.Bivand at nhh.no
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help

Cheers

Petr Pikal
petr.pikal at precheza.cz
p.pik at volny.cz




More information about the R-help mailing list