[R] Bubble chart

Jim Lemon jim at bitwrit.com.au
Thu Mar 22 08:18:15 CET 2012


On 03/22/2012 03:22 PM, ens wrote:
> I have a matrix of p-values for for each explanatory variable. Each row is an
> area of the response variable and each column is an explanatory variable.
>
> e.g.
>     PSA   pval_DOY pval_PDSIconcurrent pval_PDSIantecedent_annual_average
> pval_TMAXanomaly pval_FM100anomaly
> 1 NC06 0.96747495           0.6092668                         0.53353019
> 0.9301115        0.99801334
> 2 NC04 0.04699659           0.2759152                         0.07024752
> 0.6046828        0.03224094
> 3 NC01 0.71437394           0.9979173                         0.85296024
> 0.9977558        0.99833623
> 4 NC08 0.67315904           0.9970511                         0.51756714
> 0.7809994        0.99626038
> 5 NC07 0.55221280           0.5784208                         0.43975219
> 0.3669491        0.34898877
> 6 NC05 0.52089881           0.7191645                         0.91972153
> 0.4487460        0.94922430
>
> I want to create a visual display such that instead of #s for the p-values,
> I have a circle sized to represent the size of the p-value.
>
> symbolys() is what I've found to do this, but it isn't clear to me how to
> format the input for the function.
>
> Any suggestions?

Hi ens,
You might be interested in the "size_n_color" function (plotrix). I'll 
be uploading v3.4 shortly, and you can use that to do it like this:

psa.mat
        pval_DOY pval_PDSIconcurrent pval_PDSIaaa pval_TMAXanomaly
NC06 0.96747495           0.6092668   0.53353019        0.9301115
NC04 0.04699659           0.2759152   0.07024752        0.6046828
NC01 0.71437394           0.9979173   0.85296024        0.9977558
NC08 0.67315904           0.9970511   0.51756714        0.7809994
NC07 0.55221280           0.5784208   0.43975219        0.3669491
NC05 0.52089881           0.7191645   0.91972153        0.4487460
      pval_FM100anomaly
NC06        0.99801334
NC04        0.03224094
NC01        0.99833623
NC08        0.99626038
NC07        0.34898877
NC05        0.94922430
size_n_color(size=psa.mat,col="black",xaxlab=rep("",5),
  yaxlab=rownames(psa.mat))
staxlab(1,at=seq(2,10,by=2),colnames(psa.mat))

Jim



More information about the R-help mailing list