maybe something like this could help:
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$a, x$beta)
mapply(function(x, y) lines(x$a, x$b, col = y), x.l, 1:2)
Best,
Dimitris
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
- Original Message -
From: Petr Pikal [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Tuesday, September 26, 2006 5:40 PM
Subject: [R] lapply, plot and additional arguments
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
[EMAIL PROTECTED]
__
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.
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
__
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.