[R] Different graph type can coexisti??
Anon.
bob.ohara at helsinki.fi
Sun Dec 19 16:12:29 CET 2004
Landini Massimiliano wrote:
>Please consider a data frame
>
>A B C D
>1 4 5 0
>2 3 2 75
>3 4 1 84
>4 5 1 90
>5 3 0 100
>
>Is there a way to plot column B and C as barplot *and* D as line on the same
>graph??
>
>
>
It's not totally clear to me how you want to plot B and C, but the
following code, and ?barplot should get you what you want:
Bars=matrix(cbind(B,C), nrow=2, byrow=T)
PLOT=barplot(Bars, ylim=c(0,100))
lines(PLOT,D, col=2)
axis(1)
The only tricky thing is dealing with the way R scales the x-axis, but
fortunately the function barplot() returns the mid-points: hence this
construction.
Bob
--
Bob O'Hara
Department of Mathematics and Statistics
P.O. Box 68 (Gustaf HÃ¤llstrÃ¶min katu 2b)
FIN-00014 University of Helsinki
Finland
Telephone: +358-9-191 51479
Mobile: +358 50 599 0540
Fax: +358-9-191 51400
WWW: http://www.RNI.Helsinki.FI/~boh/
Journal of Negative Results - EEB: www.jnr-eeb.org
More information about the R-help
mailing list