views:

45

answers:

2

alt textHello All, I have the following molten data:

 X      variable       value    
1 StationA SAR11.cluster 0.001309292
2 StationB SAR11.cluster 0.002712237
3 StationC SAR11.cluster 0.002362708
4 StationD SAR11.cluster 0.002516751
5 StationE SAR11.cluster 0.004301075
6 StationF SAR11.cluster 0.0

.
.
.
etc.
etc.

I used the following code to chart a bubblechart of the data:

ggplot(foomelt, aes(x=foomelt$Station, y=variable, angle=45, size=(value))) + 
+geom_point() +  opts(theme_bw(), axis.text.x = theme_text(size=10, angle = 70)) 
+ scale_area()

All is well except that I want to ignore the 0 (zero) values and only use for the scaling of the dots values between all those that are grater than zeroes and the max value. I don't want to delete the zero values rows from the data because in order to prove a point I want all the stations and variables to be included and to have those with the zero value left blank.

I managed to use this to ignore the zero values but scaling does not work:

   ggplot(foomelt, aes(x=foomelt$Station, y=variable, angle=45, size=(value>0))) +
    + geom_point() +  opts(theme_bw(), axis.text.x = theme_text(size=10, angle = 70)) 
    + scale_area("Ratio") + scale_size_identity()

any help would be greatly appreciated.

+1  A: 

i am not sure if this is what you are looking for, but one approach to ignore the zero values while plotting the points is to modify your geom_point() statement to

geom_point(subset = .(value > 0))

this line passes only the non zero values in the data frame to be plotted.

Ramnath
Worked! thanks.
Schrodinger's Cat
A: 

Just to show how I used Ramnath's (thanks!) suggestions (so to help novices like myself):

foo= read.csv('~/Desktop/foo.csv', header=T)
foomelt = melt(foo)
foomelt$Station<-factor(foomelt$Station, levels=unique(as.character(foo[[1]]))) #to keep the order of the x axis the same
                                                                                # as in the original file`
bigfoo <- subset(foomelt, value > 0) #use only those values that are larger than 0
ggplot(bigfoo, aes(x=bigfoo$Station, y=variable, angle=45, size=(value))) +  geom_point() 
+  opts(theme_bw(), axis.text.x   = theme_text(size=9, angle = 90)) + scale_area()
Schrodinger's Cat