[R] How to Plot With Different Marker ( ‘x’ and ‘o’) Based on Condition in R
Peter Ehlers
ehlers at ucalgary.ca
Tue Jul 6 08:00:58 CEST 2010
On 2010-07-05 23:05, Gundala Viswanath wrote:
> Dear Expert,
>
> I have a data that looks like this:
>
> for_y_axis<-c(0.49534,0.80796,0.93970,0.99998)
> for_x_axis<-c(1,2,3,4)
> count<-c(0,33,0,4)
>
> What I want to do is to plot the graph using "for_x_axis" and
> "for_y_axis" but will mark
> each point with "o" if the value is equal to 0(zero) and with "x" if
> the "count" value is greater than zero.
>
> Is there a simple way to achieve that in R?
Here's one way:
.pch <- ifelse(count > 0, "x", "o")
plot(for_x_axis, for_y_axis, pch = .pch)
or you might prefer
plot(for_x_axis, for_y_axis, pch = .pch, family = "mono")
-Peter Ehlers
More information about the R-help
mailing list