[R] help filtering points from a scatterplot

Vining, Kelly Kelly.Vining at oregonstate.edu
Fri Feb 24 01:46:36 CET 2012


Dear useRs,
I'm having trouble with what is likely a very simple issue with a simple graph. I have data in the format pasted below - total from which this is a subset is > 3 million rows. I'm plotting "Window" on the x axis, and either of the other two columns on the y axis. In both the second and third columns, the values are in a range from 0 to 1. I want to be able to plot *only* the points for which the y value is below a certain cutoff - say, 0.1. But when I try to do this, I end up filtering out the whole row from the data set, and I want to retain the "Window" and just not have any y-value plotted as a point in that window. I'm attaching what I've been able to plot with ggplot - sorry for the file size. I'd like to be able to plot just the points shaded in blue, for example. 

Any help is appreciated.

Kelly V.

Code for the ggplot:

> ggplot(chr9, aes(x=Window, y=ExplantInv, colour=ExplantInv))+
+ geom_point() +
+ scale_colour_gradientn(colours=rainbow(4))


Example Data: 

> head(chr9, n=50)
   Window     Explant ExplantInv
1  168030 0.036590781  0.9634092
2  168031 1.000000000  0.0000000
3  168032 1.000000000  0.0000000
4  168033 1.000000000  0.0000000
5  168034 1.000000000  0.0000000
6  168035 1.000000000  0.0000000
7  168036 1.000000000  0.0000000
8  168037 1.000000000  0.0000000
9  168038 0.011638925  0.9883611
10 168039 0.416783189  0.5832168
11 168040 1.000000000  0.0000000
12 168041 0.031325696  0.9686743
13 168042 0.118549313  0.8814507
14 168043 1.000000000  0.0000000
15 168044 1.000000000  0.0000000
16 168045 1.000000000  0.0000000
17 168046 1.000000000  0.0000000
18 168047 1.000000000  0.0000000
19 168048 1.000000000  0.0000000
20 168049 1.000000000  0.0000000
21 168050 1.000000000  0.0000000
22 168051 0.312449302  0.6875507
23 168052 1.000000000  0.0000000
24 168053 1.000000000  0.0000000
25 168054 1.000000000  0.0000000
26 168055 1.000000000  0.0000000
27 168056 1.000000000  0.0000000
28 168057 1.000000000  0.0000000
29 168058 1.000000000  0.0000000
30 168059 0.836044243  0.1639558
31 168060 1.000000000  0.0000000
32 168061 1.000000000  0.0000000
33 168062 0.001734177  0.9982658
34 168063 1.000000000  0.0000000
35 168064 1.000000000  0.0000000
36 168065 1.000000000  0.0000000
37 168066 0.001596044  0.9984040
38 168067 1.000000000  0.0000000
39 168068 1.000000000  0.0000000
40 168069 1.000000000  0.0000000
41 168070 1.000000000  0.0000000
42 168071 1.000000000  0.0000000
43 168072 1.000000000  0.0000000


More information about the R-help mailing list