[R-meta] Meta package - Bubble plot subgroup colours

Gerta Ruecker ruecker @ending from imbi@uni-freiburg@de
Tue Sep 11 10:31:47 CEST 2018


Dear Dirk,

The colours were black and red because black = 1 and red = 2 in R. The 
trick was that I took the logical variable Fleiss93cont$region=="Europe" 
which is TRUE if the value is "Europe" and FALSE if it is "Asia" or 
whatever. By setting parentheses, this is interpreted as 1 (for 
"Europe") and 0 otherwise. Adding 1 provides 2 (that is red, for 
"Europe") and 1 (that is black) otherwise.

Of course you may set colours as you like. For the given example, you 
may write, e.g.,

cols<- c("green","violet")

to obtain these colours. For coding more than two values you need more 
colours.

Best,

Gerta


Am 11.09.2018 um 10:11 schrieb dirk.richter using upd.unibe.ch:
> Dear Gerta
>
> Many thanks for your suggestion. The code that finally worked looked like this:
>
> cols<- (Fleiss93cont$region=="Europe")+1
> bubble(mr2, col = cols, bg = cols)
>
> It seems that the colours are by default set to red and black. Is there any chance to change from red to, say, grey? Publishers often prefer non-coloured graphs.
>
> Best wishes,
> Dirk
>
> -----Ursprüngliche Nachricht-----
> Von: Gerta Ruecker < >
> Gesendet: Montag, 10. September 2018 12:49
> An:; dirk.richter using upd.unibe.ch
> Betreff: Re: [R-meta] Meta package - Bubble plot subgroup colours
>
> Dear Dirk,
>
> Try code like this one:
>
> # Load library
> library(meta)
>
> # Look at example for bubble plot, particularly mr2 (meta-regression with age as covariate)
> example(bubble)
>
> # Look at the other covariate (region)
> Fleiss93cont$region
>
> # Define colors (here only 2, black and red) cols <- (Fleiss93cont$region=="Europe") + 1
>
> # Make a coloured bubble plot
> bubble(mr2, lwd=2, col.line="blue", xlim=c(50, 70), col = cols, bg = cols)
>
> Best,
>
> Gerta
>
>
> Am 10.09.2018 um 12:24 schrieb dirk.richter using upd.unibe.ch:
>> Dear all
>>
>> I am working on a meta-regression with the meta package and I would
>> like to display two differently coloured subgroups in the bubble plot.
>> I couldn't find any advice for coding in the help and would be
>> grateful for any hints in this regard.
>>
>> Best wishes,
>> Dirk
>>
>> UNIVERSITÄRE PSYCHIATRISCHE DIENSTE BERN (UPD) AG ZENTRUM
>> PSYCHIATRISCHE REHABILITATION
>>
>> Dirk Richter, Dr. phil. habil.
>> Leiter Forschung und Entwicklung
>> Murtenstrasse 46
>> CH-3008 Bern
>> Tel. +41 31 632 4707
>> Mobil + 41 76 717 5220
>> E-Mail: dirk.richter using upd.unibe.ch
>> https://www.upd.ch/forschung/psychiatrische-rehabilitation/
>>
>> University of Bern Psychiatric Services Center for Psychiatric
>> Rehabilitation Dirk Richter, Dr. phil., PhD Head of Research and
>> Development Murtenstrasse 46
>> CH-3008 Bern
>> Switzerland
>> Phone +41 31 632 4707
>> Mobile Phone +41 76 717 5220
>>
>> _______________________________________________
>> R-sig-meta-analysis mailing list
>> R-sig-meta-analysis using r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis

-- 

Dr. rer. nat. Gerta Rücker, Dipl.-Math.

Institute of Medical Biometry and Statistics,
Faculty of Medicine and Medical Center - University of Freiburg

Stefan-Meier-Str. 26, D-79104 Freiburg, Germany

Phone:    +49/761/203-6673
Fax:      +49/761/203-6680
Mail:     ruecker using imbi.uni-freiburg.de
Homepage: https://portal.uni-freiburg.de/imbi/persons/ruecker?set_language=en



More information about the R-sig-meta-analysis mailing list