[R] Data labels in R

arun smartpink111 at yahoo.com
Sun Sep 15 19:33:22 CEST 2013


Hi,
Try:
lab<- as.character(x[,3])
library(lattice)
xyplot(y~time(y),type="b",xlab="Date",ylab="Price",scales=list(x=list(at=time(y),labels=format(time(y),"%b-%d"))),
panel=function(x, y, ...) {
               panel.xyplot(x, y, ...);
               ltext(x=x, y=y, labels= lab, pos=1, offset=1, cex=0.8)})

A.K.




----- Original Message -----
From: Ankur Seth <ankurseth82 at gmail.com>
To: jim holtman <jholtman at gmail.com>
Cc: r-help <r-help at stat.math.ethz.ch>
Sent: Sunday, September 15, 2013 12:43 PM
Subject: Re: [R] Data labels in R

I want to put labels a,b,c,d on the data points

x<-data.frame(c(1,2,3,4),c(1,4,9,16),c("a","b","c","d"),
as.Date(c("01-10-2013", "02-10-2013","03-10-2013","04-10-2013"),
"%d-%m-%Y"))
colnames(x)<-c("x", "sq", "lables","dates")
y<-subset(x, select=c(dates,x,sq))
y<-read.zoo(y)
plot(y, plot.type="single", xlab="Date", ylab="Price")




On Sun, Sep 15, 2013 at 9:16 PM, jim holtman <jholtman at gmail.com> wrote:

> Read the help file on 'plot' and look at some of the examples to see
> how to place labels in various places on a plot.  This is not
> difficult if you have read any of the documentation.
>
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
> Tell me what you want to do, not how you want to do it.
>
>
> On Sun, Sep 15, 2013 at 11:37 AM, Ankur Seth <ankurseth82 at gmail.com>
> wrote:
> > I need to put labels in plot in R. Can someone please help? The labels
> are
> > in the excel file and loaded into "lables"
> >
> > library(xlsx)
> > library(zoo)
> >
> > fPTAnalysis<-"Input.xls"
> > data<-read.xlsx(fPTAnalysis,9)
> >
> > lables<-subset(data, select=c(Labels))
> > data<-subset(data, select=c(Date,col1, col2 ))
> > data<-read.zoo(data)
> >
> >
> >
> > plot(data)
> >
> > --
> > Regards,
> > Ankur Seth
> >
> >         [[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.
>



-- 
Regards,
Ankur Seth

    [[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.




More information about the R-help mailing list