As there is no answer yet. Here is one:
library(ggplot2)
library(reshape2)
Ex <- read.csv("C:/Users/Thomas/Desktop/StackOverflowEx (3).csv")
gg <- melt(Ex, id = c("Item", "Total", "Admin"))
# put in number of plots here
noPlots <- 4
# save all variables in a seperate vector to select in for-loop
allVars <- unique(gg$variable)
noVars <- length(allVars)
# indices for plotting variables
plotSequence <- c(seq(0, noVars-1, by = noPlots), noVars)
# pdf("plotpath.pdf") # uncomment to save the resulting plots in a pdf file
# loop over the variables to plot
for(ii in 2:length(plotSequence)){
# select start and end of variables to plot
start <- plotSequence[ii-1] + 1
end <- plotSequence[ii]
# subset the variables and save new temporary data.frame
tmp <- subset(gg, variable %in% allVars[start:end])
cat(unique(tmp$variable), "\n")
# generate plot
p <- ggplot(tmp, aes(x = Total, y = Admin))+
geom_point(colour = "dark green", size = 1.5)+
geom_point(aes(y = value, color = variable))+
geom_smooth(aes(y = value, fill = variable),
method = loess, size = 1, linetype = 1, se = T)+
facet_wrap(~variable, ncol = 2, nrow = 1000)+
ylim(0, 1)+
labs(x = "Expected", y = "Admin")
print(p)
}
# dev.off()