[R] Drawing circles on a chart

Santosh Srinivas santosh.srinivas at gmail.com
Wed Nov 3 03:58:50 CET 2010

```Thanks Gabor. I used melt to transform the data and plot using balloonplot.

tData <- structure(list(A = c(0.2, 0.13, 0.05, 0.1, 0.02, 0.18, 0.09, 0.06,
0.13), B = c(0.15, 0.06, 0.09, 0.02, 0.03, 0.12, 0.01, 0.15, 0.06), C
= c(-0.1, 0, -0.07, -0.06, -0.05, -0.05, -0.06, -0.08, -0.07), D =
c(-0.15, -0.05, -0.1, -0.03, -0.13, -0.04, -0.1, -0.04, -0.15), E =
c(-0.17, -0.16, -0.08, -0.07, -0.09, -0.14, -0.1, -0.05, 0)), .Names =
c("A", "B", "C", "D", "E"), class = "data.frame", row.names = c(NA,
-9L))

tData\$Period <- rownames(tData)

tData.m <- melt(tData)

# need to find a way to adjust the color for -ve values
balloonplot(tData.m\$Period,tData.m\$variable,abs(tData.m\$value))

-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com]
Sent: 03 November 2010 07:51
To: Santosh Srinivas
Cc: r-help at r-project.org
Subject: Re: [R] Drawing circles on a chart

On Tue, Nov 2, 2010 at 10:07 PM, Santosh Srinivas
<santosh.srinivas at gmail.com> wrote:
> Dear Group,
> I have the following data matrix which is a timeseries.
>
>> dput(tData)
> structure(list(A = c(0.2, 0.13, 0.05, 0.1, 0.02, 0.18, 0.09,
> 0.06, 0.13), B = c(0.15, 0.06, 0.09, 0.02, 0.03, 0.12, 0.01,
> 0.15, 0.06), C = c(-0.1, 0, -0.07, -0.06, -0.05, -0.05, -0.06,
> -0.08, -0.07), D = c(-0.15, -0.05, -0.1, -0.03, -0.13, -0.04,
> -0.1, -0.04, -0.15), E = c(-0.17, -0.16, -0.08, -0.07, -0.09,
> -0.14, -0.1, -0.05, 0)), .Names = c("A", "B", "C", "D", "E"), class =
> "data.frame", row.names = c(NA,
> -9L))
>
>
> I am trying to display this data in a graphic. The values vary from -0.2
to
> +0.2
> There should be a table with 5 Rows and 9 Columns. Rows labeled A to E and
> Columns labeled 1 to 9.
> Inside each cell there should be a circle (sphere preferable) with radius
of
> mod(data value). The color should be either red or green depending on -ve
or
> +ve and the intensity should be based on the value of the datapoint.
>

See balloonplot in the gplots package.

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

```