r - Plot graphs next to a single output -
i have dataset dataframe:
structure(list(year = c(2001l, 2002l, 2003l, 2004l, 2005l, 2006l, 2007l, 2001l, 2002l, 2003l, 2004l, 2005l, 2006l, 2007l, 2001l, 2002l, 2003l, 2004l, 2005l, 2006l, 2007l, 2001l, 2002l, 2003l, 2004l, 2005l, 2006l, 2007l, 2001l, 2002l, 2003l, 2004l, 2005l, 2006l, 2007l, 2001l, 2002l, 2003l, 2004l, 2005l, 2006l, 2007l ), volume = c(21l, 44l, 37l, 23l, 46l, 21l, 69l, 21l, 44l, 37l, 23l, 46l, 21l, 69l, 21l, 44l, 37l, 23l, 46l, 21l, 69l, 21l, 44l, 37l, 23l, 46l, 21l, 69l, 21l, 44l, 37l, 23l, 46l, 21l, 69l, 21l, 44l, 37l, 23l, 46l, 21l, 69l), stock = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 2l, 2l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 4l, 4l, 4l, 4l, 4l, 4l, 4l, 5l, 5l, 5l, 5l, 5l, 5l, 5l, 6l, 6l, 6l, 6l, 6l, 6l, 6l), .label = c("stock1", "stock2", "stock3", "stock4", "stock5", "stock6"), class = "factor")), .names = c("year", "volume", "stock"), class = "data.frame", row.names = c(na, -42l )) what have until know
library(ggplot2) p <- ggplot(df, aes(x = df$year, y = df$volume)) + geom_line(aes(color = "red")) + facet_grid(stock ~ ., scales = "free_x") + theme(legend.position = left)

Comments
Post a Comment