Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

install.packages("benford.

analysis")
library(benford.analysis)
data(corporate.payment)
cp<-benford(corporate.payment$Amount,2,sign="both")
cp #prints
plot(cp) #plots

head(suspectsTable(cp),10)#prints the digits by decreasing order of discrepancies


suspects <- getSuspects(cp, corporate.payment, how.many=2)
suspects
duplicatesTable(cp)
duplicates <- getDuplicates(cp, corporate.payment,how.many=2)
MAD(cp) #gets the Mean Absolute Deviation
chisq(cp) #gets the Chi-squared test

#gets observations starting with 50 or 99


digits_50_and_99<-getDigits(cp, corporate.payment, digits=c(11,50, 99))
digits_50_and_99

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)

lgd <- sort(unique(da$Year))


legend("topleft", legend = lgd, fill = c("darkblue","red","Green","Yellow"),horiz =
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")

You might also like