[R] Two Factors and a Numeric Variable in a Plot

Bert Gunter gunter.berton at gene.com
Wed Feb 9 19:27:48 CET 2011


Sounds like a job for "trellising" using ?xyplot or "faceting" using
ggplot in the gglplot2 package  (two terms for the same idea, but
different API's for implementation). I suggest you check the R Graph
Gallery at:

http://addictedtor.free.fr/graphiques/

for ideas. I'm sure you'll find both design AND code for
implementation that will suit your needs there.

-- Bert

On Wed, Feb 9, 2011 at 10:01 AM, Rodrigo Aluizio <r.aluizio at gmail.com> wrote:
> Hi list.
>
> I'm trying to plot a graph "by" factors. Exactly, the x axis are my depths
> (as.factor), my left y axis are my transects (also as.factor) and I want to
> plot the mean and standard deviation (three samples per factor combination)
> of my SW (numeric) variable. The second y axis (at the right) will,
> probably, need to be displayed several times (for both left y axis "values"
> - A and B).
>
> Below is a part of what I'm trying to plot. The problem is that this time I
> have no idea on how to do so! Nor even how to begin. Any ideas?
>
>
>
>
> Samples
>
> SW
>
> Depth
>
> Transect
>
>
> A01_R1
>
> 0.782163
>
> 1
>
> A
>
>
> A01_R2
>
> 0.678205
>
> 1
>
> A
>
>
> A01_R3
>
> 0.673248
>
> 1
>
> A
>
>
> A02_R1
>
> 0.775284
>
> 2
>
> A
>
>
> A02_R2
>
> 0.866862
>
> 2
>
> A
>
>
> A02_R3
>
> 0.870709
>
> 2
>
> A
>
>
> A03_R1
>
> 0.881894
>
> 3
>
> A
>
>
> A03_R2
>
> 0.820127
>
> 3
>
> A
>
>
> A03_R3
>
> 0.867685
>
> 3
>
> A
>
>
> A04_R1
>
> 0.906944
>
> 4
>
> A
>
>
> A04_R2
>
> 0.941329
>
> 4
>
> A
>
>
> A04_R3
>
> 0.924741
>
> 4
>
> A
>
>
> A05_R1
>
> 0.973075
>
> 5
>
> A
>
>
> A05_R2
>
> 0.96872
>
> 5
>
> A
>
>
> A05_R3
>
> 0.954444
>
> 5
>
> A
>
>
> B01_R1
>
> 0.912486
>
> 1
>
> B
>
>
> B01_R2
>
> 0.931048
>
> 1
>
> B
>
>
> B01_R3
>
> 0.921488
>
> 1
>
> B
>
>
> B02_R1
>
> 0.94216
>
> 2
>
> B
>
>
> B02_R2
>
> 0.905211
>
> 2
>
> B
>
>
> B02_R3
>
> 0.950491
>
> 2
>
> B
>
>
> B03_R1
>
> 0.951062
>
> 3
>
> B
>
>
> B03_R2
>
> 0.945663
>
> 3
>
> B
>
>
> B03_R3
>
> 0.956717
>
> 3
>
> B
>
>
> B04_R1
>
> 0.974706
>
> 4
>
> B
>
>
> B04_R2
>
> 0.966461
>
> 4
>
> B
>
>
> B04_R3
>
> 0.949697
>
> 4
>
> B
>
>
> B05_R1
>
> 0.958339
>
> 5
>
> B
>
>
> B05_R2
>
> 0.952168
>
> 5
>
> B
>
>
> B05_R3
>
> 0.96301
>
> 5
>
> B
>
>
>
> Thank you very much.
>
> Regards.
>
>
>
> -------------------------------------------------------------------
>
> MSc.  <mailto:r.aluizio at gmail.com> Rodrigo Aluizio
>
> Centro de Estudos do Mar/UFPR
>
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics
467-7374
http://devo.gene.com/groups/devo/depts/ncb/home.shtml



More information about the R-help mailing list