You must learn to structure your data and how to make a reproducible example . It is very difficult to process data in such an unstructured format. Not only for you, but also for us.
mdf <- read.table( text="Company 2011 2013 2011 2013 2011 2013 Company1 300 350 290 300 295 290 Company2 320 430 305 301 300 400 Company3 310 420 400 305 400 410", header = TRUE, check.names=FALSE ) library("reshape2") cat1 <- melt(mdf[c(1,2,3)], id.vars="Company", value.name="value", variable.name="Year") cat1$Category <- "Category1" cat2 <- melt(mdf[c(1,4,5)], id.vars="Company", value.name="value", variable.name="Year") cat2$Category <- "Category2" cat3 <- melt(mdf[c(1,6,7)], id.vars="Company", value.name="value", variable.name="Year") cat3$Category <- "Category3" mdf <- rbind(cat1, cat2, cat3) head(mdf) Company Year value Category 1 Company1 2011 300 Category1 2 Company2 2011 320 Category1 3 Company3 2011 310 Category1 4 Company1 2013 350 Category1 5 Company2 2013 430 Category1 6 Company3 2013 420 Category1
This can be automated, of course, if the number of categories is very large:
library( "plyr" ) mdf <- adply( c(1:3), 1, function( cat ){ tmp <- melt(mdf[ c(1, cat*2, cat*2+1) ], id.vars="Company", value.name="value", variable.name="Year") tmp$Category <- paste0("Category", cat) return(tmp) } )
But if you cannot push all this data back and forth from the very beginning, you must do it.
Using faces
ggplot2 has built-in support for faceted graphs displaying data of the same type, if they can be a subset of one (or more) variables. See ? facet_wrap ? facet_wrap or ? facet_grid ? facet_grid .
ggplot(data=mdf, aes(x=Year, y=value, group = Company, colour = Company)) + geom_line() + geom_point( size=4, shape=21, fill="white") + facet_wrap( "Category" )

Getting individual schedules
Alternatively, you can multiply your data.frame with the appropriate variable and save the individual graphs in a list:
librayr("plyr") ll <- dlply( mdf, "Category", function(x){ ggplot(data=x, aes(x=Year, y=value, group = Company, colour = Company)) + geom_line() + geom_point( size=4, shape=21, fill="white") }) ll[["Category1"]]