[R] two graphs in one figure?

hadley wickham h.wickham at gmail.com
Thu Apr 10 17:34:43 CEST 2008


On Thu, Apr 10, 2008 at 8:36 AM, ONKELINX, Thierry
<Thierry.ONKELINX at inbo.be> wrote:
> Dear Anne-Katrin,
>
>  You could use ggplot to do this. The example below works, although it generates some warnings.
>
>  library(ggplot2)
>  dataset <- data.frame(x = 0:55, y = rnorm(56, 10), z = runif(56, 9, 11))
>  ggplot(data = dataset) + geom_bar(aes(x = factor(x), y = y), position = "dodge") + geom_line(aes(x = x, y = z))

ggplot(data = dataset, aes(factor(x), y)) + geom_bar() +
geom_line(aes(y=z, group=1))

does basically the same thing, but without warnings.

Hadley

-- 
http://had.co.nz/



More information about the R-help mailing list