[R] getting a title in a plot during an lapply

Leeds, Mark (IED) Mark.Leeds at morganstanley.com
Thu Nov 16 22:09:08 CET 2006


In my code below tempa and tempb are numeric vectors that I combined
into a dataframe along with the deciles of tempa.
I have an lapply statement that goes through the dataframe and does ten
plots according to the appropriate decile.
The code is below and it works fine. There are no bugs so I figure there
was no need to include structure statements on the data.
Also, I don't want to use coplot because the axes get sort of messed up
because of outliers.

tempa.deciles<-cut(tempa,breaks=quantile(tempa,probs=seq(0,1,0.1)),inclu
de.lowest=TRUE)
df<-data.frame(tempa,tempb,tempa.deciles)
levels(df$tempa.deciles)<-paste("Decile ",1:10,sep="")
lapply(split(df, df$tempa.deciles), function(x) {
print(cor(x$tempa,x$tempb)); plot(x$tempa,x$tempb);

I would like to include a title on each plot so that I can recognize
which plot goes with which decile but I don't
know how to do that basically because I can't figure out what lapply is
looping over by number. I definitely
looked around in various R books but I was not successful. Thanks for
your help.
--------------------------------------------------------

This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}



More information about the R-help mailing list