Example of Benford Tests in R:

Resources:

library(BenfordTests)
## Warning: package 'BenfordTests' was built under R version 3.2.2
# Academic users, please be sure to use: citation("BenfordTests").
# Feel free to contact the Maintainer about liscensing, feature requests, etc.
# Use suppressPackageStartupMessages to eliminate package startup messages.

example(BenfordTests)
## 
## BnfrdT> #Set the random seed to an arbitrary number
## BnfrdT> set.seed(421)
## 
## BnfrdT> #Create a sample satisfying Benford's law
## BnfrdT> X<-rbenf(n=20)
## 
## BnfrdT> #Look at sample
## BnfrdT> X
##  [1] 6.159420 1.396476 5.193371 2.064033 7.001284 5.006184 7.950332
##  [8] 4.822725 3.386809 1.619609 2.080063 2.242473 1.944697 5.460581
## [15] 6.443031 2.662821 2.079283 3.703353 1.364175 3.354136
## 
## BnfrdT> #Look at the first digits of the sample
## BnfrdT> signifd(X)
##  [1] 6 1 5 2 7 5 7 4 3 1 2 2 1 5 6 2 2 3 1 3
## 
## BnfrdT> #Perform a Chi-squared Test on the sample's first digits using defaults
## BnfrdT> chisq.benftest(X)
## 
##  Chi-Square Test for Benford Distribution
## 
## data:  X
## chisq = 5.9932, p-value = 0.648
## 
## 
## BnfrdT> #p-value = 0.648
## BnfrdT> 
## BnfrdT> 
## BnfrdT>
citation("BenfordTests")
## 
## To cite package 'BenfordTests' in publications use:
## 
##   Dieter William Joenssen (2015). BenfordTests: Statistical Tests
##   for Evaluating Conformity to Benford's Law. R package version
##   1.2.0. http://CRAN.R-project.org/package=BenfordTests
## 
## A BibTeX entry for LaTeX users is
## 
##   @Manual{,
##     title = {BenfordTests: Statistical Tests for Evaluating Conformity to Benford's Law},
##     author = {Dieter William Joenssen},
##     year = {2015},
##     note = {R package version 1.2.0},
##     url = {http://CRAN.R-project.org/package=BenfordTests},
##   }