[R] How to produce serveral plots with pairs of vectors

Bert Gunter gunter.berton at gene.com
Sun Apr 8 16:55:25 CEST 2012


Please do your homework first: Read at least the beginning of An
Introduction to R or other R tutorial -- there are many. I say this
because in your post below you do not seem to realize that R is case
sensitive, and you do not seem to know the difference between a data
frame and a column thereof and/or how to index them . Saying you are a
newbie is not an excuse to avoid making a minimal effort to learn what
you need to know. R is not a point and click social application and
has a fairly steep (or more properly shallow, as Sarah Goslee, I
believe, has noted) learning curve associated with it. If you prefer
to avoid this, you may wish to try R Commander, Deducer, RStudio or
other R GUI package to avoid this -- check the RGUI page on CRAN for
what's there. Obviously, you get only limited functionality in  GUI,
but it may be sufficient for you.

That said, something like

for(i in 1:5) boxplot( dimensionen[,i] ~ gruppe[,i] )

should work, but you will probably be unhappy with the captioning and
axis labels. Proper main titles and axis labels can be programatically
built, but that requires you to learn a good deal more R than you
appear to presently know.

-- Bert

On Sun, Apr 8, 2012 at 5:51 AM, slyrs66 <andreas.fahr at gmx.de> wrote:
> Dear R-Users,
> I have a newbie-question about producing several plots with five variable
> pairs within in one code (loop).
>
> Problem:
> I define two objects, erveryone has five vectors (columns /variables):
>
> dimensionen <- data.frame(meinspss$attr_diff_gesamt,
> meinspss$finanz_diff_gesamt, meinspss$leist_diff_gesamt,
> meinspss$soz_diff_gesamt, meinspss$wert_diff_gesamt)
> gruppe <- data.frame(meinspss$R1_02, meinspss$R2_02,
> meinspss$R3_02,meinspss$R4_02,meinspss$R5_02)
>
> Now I would like to plot five similar graphs (beanplots, boxplots) for every
> pair of vectors (dimension by gruppe) .
>
> This works: box plot (dimensioned) - I receive a plot with 5 boxes.
>
> This does not work: boxplot (Dimensionen ~ Gruppe) - I would like to receive
> 5 plots
>
> I get the error message:
> Fehler in model.frame.default(formula = dimensionen ~ gruppe) :
> ungültiger Typ (list) für die Variable 'Dimensionen'
>
> Any help is very much appreciated!
>
> Happy Easter
> slyrs66
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-produce-serveral-plots-with-pairs-of-vectors-tp4540968p4540968.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list