Re: [R] Using ltext

About this list Date view Thread view Subject view Author view Attachment view

From: Andrew C. Ward (s195404@student.uq.edu.au)
Date: Fri 24 Jan 2003 - 09:03:12 EST


Message-id: <1043359392.3e3066a029a23@my.uq.edu.au>

Nirmala,

You will need to use a panel function to label the points, I think.
Try the following code. I'm assuming you really want a lattice plot.

xyplot(p ~ q, data=a, country=a$country, subscripts=subscripts,
       panel=function(x,y,subscripts,country,...) {
          ltext(x,y,country[subscripts])
       })

Regards,

Andrew C. Ward

CAPE Centre
Department of Chemical Engineering
The University of Queensland
Brisbane Qld 4072 Australia
andreww@cheque.uq.edu.au

Quoting Nirmala Ravishankar <ravishan@fas.harvard.edu>:

>
> So, I am trying to label the points in a graph, but cannot quite figure
> out how to use ltext. I get an error about the lengths of x and y not
> being the same, when I have defined them as the same.
>
> > a <- data.frame(num = 1:4)
> > a$country <- c("A", "B", "C", "D")
> > a$p <- c(0.34, .54, .41, .33)
> > a$q <- c(.07, .03, .05, .10)
>
> > a
> num country p q
> 1 1 A 0.34 0.07
> 2 2 B 0.54 0.03
> 3 3 C 0.41 0.05
> 4 4 D 0.33 0.10
>
> > xyplot(p ~ q, data = a, ltext(x=x, y=y, label = a$country))
> Error in xy.coords(x, y) : x and y lengths differ
>
> > xyplot(p ~ q, data = a, groups = as.character(a$country), ltext(x=x,
> y=y, label = groups[subscripts]))
> Error in xy.coords(x, y) : x and y lengths differ
>
> - Nirmala
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help
>

______________________________________________
R-help@stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:20 EST