On 2012-08-24 09:12, ravi wrote:
Hi,
I am interested in implementing a special variant of
balloonplot.  Let me
explain with an example dataset from the reference manual :

library(gplots)
data(Titanic)
dframe<-as.data.frame(Titanic)
survived<-dframe[dframe$Survived=="Yes",]
attach(survived)
balloonplot(x=Class,y=list(Age,Sex),z=Freq,sort=TRUE,show.zeros=TRUE,cum.margins=FALSE,
             main="BalloonPlot : Surviving passengers") # standard plot
# Now comes the attempt at something more special
FreqThresh=50 # A threshold level
Freqdev<-Freq-FreqThresh # A new variable
colors=ifelse(Freqdev>0,"green","magenta")
balloonplot(x=Class,y=list(Age,Sex),z=Freqdev,sort=TRUE,show.zeros=TRUE,cum.margins=FALSE,dotcol=colors,
show.margins=FALSE,main="BalloonPlot : Surviving passengers")

I am interested in a table with the
values unchanged from the titanic dataframe. These values should be highlighted
in balloons in two different colours, let’s say, green and magenta. For
positive values of Freqdev, the balloons will be green and have a size
depending on the magnitude of Freqdev. For negative values of Freqdev, the 
balloons
will have a colour of magenta and have a size proportional to the absolute
values of Freqdev.
I am not sure if a simple tweak can lead to a solution.

I see that you have by now received help on how to access the
source code for balloonplot.default. Here's the change you
probably have in mind for the above:

In balloonplot.default(), find the following two lines (they're
in a function myscale() defined within balloonplot):

        X[X<0] <- 0
        X <- sqrt(X)

Comment out these lines and replace them with

        X <- sqrt(abs(X))

Save the resulting function as myballoonplot and use that in
your code.

While you're at it, you might remove the attach(survived)
statement and use

  with(survived, myballoonplot(....))

Peter Ehlers


I will appreciate any help that I can get.
Thanks,
Ravi

        [[alternative HTML version deleted]]


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to