[R] ggplot2 example

Felipe Carrillo mazatlanmexico at yahoo.com
Thu Jan 22 23:56:32 CET 2009


 I need to plot two graphics just like the example below but for some reason your example crashes. Using facet_wrap seems to be the cause:
library(ggplot2)
upper <- with(economics, data.frame(date,value = psavert, position = "upper"))
upper
lower <- with(economics, data.frame(date,value = unemploy,position = "lower"))
lower
#upper$date <- as.Date(upper$date,"%m/%d/%Y")
#lower$date <- as.Date(lower$date,"%m/%d/%Y")
ggplot(mapping = aes(x=date, y=value)) + geom_line(data = upper) + geom_area(data = lower)  +
   facet_wrap(~ position, scale = "free_y",ncol=1)


Felipe D. Carrillo  Supervisory Fishery Biologist  Department of the Interior  US Fish & Wildlife Service  California, USA




More information about the R-help mailing list