Professional Documents
Culture Documents
Barplot in R
Barplot in R
analysis")
library(benford.analysis)
data(corporate.payment)
cp<-benford(corporate.payment$Amount,2,sign="both")
cp #prints
plot(cp) #plots
data(census.2000_2010)
c2010 <- benford(census.2000_2010$pop.2010)
digits.10.25 <- getDigits(c2010, census.2000_2010, c(10,25))
getDuplicates(c2010 , data, how.many=2)
-----------------------------------------------------------------------------------
---------------------
rm(list=ls())
da<-read.csv("C:\\Users\\jitendra.jha\\Desktop\\fataldata.csv",header=TRUE)
attach(da)
View(da)
names(da)
dim(da)
str(da)
summary(da)
library(psych)
describe(da)
model<-glm(Fatilities~Driver.Age,family="poisson",data=da)
summary(model)
counts<-table(da$Year,da$Month)
barplot(counts, main="Fatalities by Years & Months",xlab="Month",ylab="Persons
killed",ylim=c(0,6),las=1,col=c("darkblue","red","Green","Yellow"),legend =
rownames(counts),names.arg=c("Jan","Feb","March","April","May","June","July","Aug",
"Sep","Oct","Nov","Dec"),cex.names=1,,beside=TRUE)
counts<-table(da$Year,da$Month)
barplot(counts, main="Fatalities by Years &
Months",xlab="Month",col=c("darkblue","red","Green","Yellow"),legend =
rownames(counts),beside=TRUE)
counts<-table(da$Year,da$Month)# 1
barplot(counts, main="Fatalities by Years &
Months",names.arg=c("Jan","Feb","March","April","May","June","July","Aug","Sep","Oc
t","Nov","Dec"),xlab="Month",ylab="Persons
killed",ylim=c(0,6),col=c("darkblue","red","Green","Yellow"),legend =
rownames(counts),cex.names=1,beside=TRUE)
counts<-table(da$Year,da$Catdriverage)# 2
barplot(counts, main="Fatalities by Years & Driver.Age ",xlab="Month",ylab="Persons
killed",ylim=c(0,15),col=c("darkblue","red","Green","Yellow"),legend =
rownames(counts),cex.names=1.5,beside=TRUE)
counts<-table(da$Year,da$DL.Issuing.State)# 3
barplot(counts, main="Fatalities by Years & Driver.Age ",xlab="Month",ylab="Persons
killed",ylim=c(0,20),col=c("darkblue","red","Green","Yellow"),legend =
rownames(counts),cex.names=1.5,beside=TRUE)
===================================================================================
================================
library(ggplot2)
da<- read.csv("C:\\Users\\jitendra.jha\\Desktop\\Cluster.csv")
da
dim(da)
head(da)
names(da)
p<-
qplot(Actual.V.U.,EPK,data=da,size=factor(Cbus),shape=Managed.by,color=Depot,facets
=CkmEffi~CEPB,main="EPB",xlab="Vehicle Utilization",ylab="EPK")
p + theme_bw()
p + theme_stata() + scale_color_stata()
p +
theme(axis.title=element_text(face="bold.italic",size="12",color="red"),legend.posi
tion="top")
p<-
qplot(Actual.V.U.,EPB,data=da,size=factor(Cbus),shape=Managed.by,color=Depot,facets
=CkmEffi~CEPK,main="EPK",xlab="Vehicle Utilization",ylab="EPB")
p + theme_bw(base_size = 11)
p+theme_gray()
p+theme_light()
p+theme_dark()
p +
theme(axis.title=element_text(face="bold.italic",size="12",color="red"),legend.posi
tion="right")