[R] lapply, plot and additional arguments

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Tue 26 Sep 2006 - 15:40:32 GMT


Dear all

Hopefully somebody will know the answer.

I have some list

x <- data.frame(a = 1:9, beta = exp(-4:4), logic = rep(c(TRUE,FALSE), c(5,4)))
x.l <- split(x, x$logic)
plot(x.l$a, x.l$beta)

and I want to plot lines color coded according to logic variable

lapply(x.l, function(x, ...) lines(x$a, x$beta, col=1:2))
lapply(x.l, function(x,...) lines(x$a,x$beta), col=1:2)
lapply(x.l, function(x,...) lines(x$a,x$beta, ...), col=1:2)

Well, lapply seems to ignore my best attempts to persuade it to use different colours for each part of x.l list.

Anybody knows how to code different colours when using lapply for such plotting?

At present time I use a loop but maybe lapply could do it too.

Best regards.
Petr

Petr Pikal
petr.pikal@precheza.cz



R-help@stat.math.ethz.ch 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. Received on Wed Sep 27 01:48:13 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 26 Sep 2006 - 16:31:00 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.