prashanthns — Jul 19, 2014, 4:38 PM
rm(list=ls(all=TRUE))
rsby <- read.csv("~/Documents/Official/IPH/RTI work/Central online RTIs/RSBY /rsby_enrolment_perc.csv", header=TRUE)
years<-c("2008","2009","2010","2011","2012","2013")
row.names(rsby)<-years
View(rsby)
attach(rsby)
yearsplot<-as.numeric(years)
plot(yearsplot,karnataka)
##ggplot2
library("ggplot2", lib.loc="/Library/Frameworks/R.framework/Versions/3.1/Resources/library")
p1<-ggplot(data=rsby, aes(x=years, y=andhra, group=1)) + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p2<-ggplot(data=rsby, aes(x=years, y=arunachal, group=1)) + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p3<-ggplot(data=rsby, aes(x=years, y=assam, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p4<-ggplot(data=rsby, aes(x=years, y=bihar, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p5<-ggplot(data=rsby, aes(x=years, y=chandigarh, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p6<-ggplot(data=rsby, aes(x=years, y=chattisgarh, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p7<-ggplot(data=rsby, aes(x=years, y=delhi, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p8<-ggplot(data=rsby, aes(x=years, y=goa, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p9<-ggplot(data=rsby, aes(x=years, y=gujarat, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p10<-ggplot(data=rsby, aes(x=years, y=haryana, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p11<-ggplot(data=rsby, aes(x=years, y=himachal, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p12<-ggplot(data=rsby, aes(x=years, y=jamukashmir, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p13<-ggplot(data=rsby, aes(x=years, y=jharkhand, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p14<-ggplot(data=rsby, aes(x=years, y=karnataka, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p15<-ggplot(data=rsby, aes(x=years, y=kerala, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p16<-ggplot(data=rsby, aes(x=years, y=mp, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p17<-ggplot(data=rsby, aes(x=years, y=maharashtra, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p18<-ggplot(data=rsby, aes(x=years, y=manipur, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p19<-ggplot(data=rsby, aes(x=years, y=meghalaya, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p20<-ggplot(data=rsby, aes(x=years, y=mizoram, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p21<-ggplot(data=rsby, aes(x=years, y=nagaland, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p22<-ggplot(data=rsby, aes(x=years, y=orissa, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p23<-ggplot(data=rsby, aes(x=years, y=pondicherry, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p24<-ggplot(data=rsby, aes(x=years, y=punjab, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p25<-ggplot(data=rsby, aes(x=years, y=rajasthan, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p26<-ggplot(data=rsby, aes(x=years, y=tamilnadu, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p27<-ggplot(data=rsby, aes(x=years, y=tripura, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p28<-ggplot(data=rsby, aes(x=years, y=up, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p29<-ggplot(data=rsby, aes(x=years, y=uttarakhand, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
p30<-ggplot(data=rsby, aes(x=years, y=wb, group=1)) + geom_line() + geom_line(colour="red",size=3) + geom_point(colour="red", size=4, shape=21, fill="white") + ylim(0,100)
# Multiple plot function
# From http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects)
# - cols: Number of columns in layout
# - layout: A matrix specifying the layout. If present, 'cols' is ignored.
#
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE),
# then plot 1 will go in the upper left, 2 will go in the upper right, and
# 3 will go all the way across the bottom.
#
multiplot <- function(..., plotlist=NULL, file, cols=1, layout=NULL) {
require(grid)
# Make a list from the ... arguments and plotlist
plots <- c(list(...), plotlist)
numPlots = length(plots)
# If layout is NULL, then use 'cols' to determine layout
if (is.null(layout)) {
# Make the panel
# ncol: Number of columns of plots
# nrow: Number of rows needed, calculated from # of cols
layout <- matrix(seq(1, cols * ceiling(numPlots/cols)),
ncol = cols, nrow = ceiling(numPlots/cols))
}
if (numPlots==1) {
print(plots[[1]])
} else {
# Set up the page
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout))))
# Make each plot, in the correct location
for (i in 1:numPlots) {
# Get the i,j matrix positions of the regions that contain this subplot
matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE))
print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row,
layout.pos.col = matchidx$col))
}
}
}
multiplot (p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18,p19,p20,p21,p22,p23,p24,p25,p26,p27,p28,p29,p30,cols=6)
Loading required package: grid
Warning: Removed 3 rows containing missing values (geom_point).