[R] Plot multiple variables: label points

David L Carlson dcarlson at tamu.edu
Fri Aug 17 18:00:01 CEST 2012


When you call plot with more than two columns, uses the pairs() function.
That means you have to write a panel function. Here are a couple of 
relatively simple examples:

pairs(variable[,2:4], panel=function(x, y, ...) text(x, y, 
     variable$group))

pairs(variable[,2:4], panel=function(x, y, ...) points(x, y, 
     pch=as.numeric(variable$group)))

The first one plots the group instead of a point and the second
one plots a symbol for each group.

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Bert Gunter
> Sent: Friday, August 17, 2012 9:18 AM
> To: cm256
> Cc: r-help at r-project.org
> Subject: Re: [R] Plot multiple variables: label points
> 
> ?text
> 
> Have you read the "Introduction to R" tutorial. If not, do so before
> further posting. If so, re-read section 12.2.
> 
> -- Bert
> 
> 
> 
> On Fri, Aug 17, 2012 at 6:33 AM, cm256 <d-nex at gmx.at> wrote:
> > Hello, I have a data.frame with 10-15 entries which looks like this:
> >
> >         group time1 time2 time3
> > 1      F18  4394.500  21043.50 14949.00
> > 2      F25  4678.000  23727.65 15683.12
> > 3      F30  4909.775  23487.60 16724.40
> >
> > I plot this with:
> > plot(variable[,2:4])
> > so that a plot with 3 rows and 3 lines for time1, time2 and time3
> appears.
> >
> > Is it somehow possible to label the data points with the values
> stored in
> > group (F18, F25...)?
> >
> >
> >
> > --
> > View this message in context: http://r.789695.n4.nabble.com/Plot-
> multiple-variables-label-points-tp4640611.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
> 
> ______________________________________________
> 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.




More information about the R-help mailing list