carloscinelli / benford.analysis

Tools that make it easier to use Benford’s law for data validation and forensic analytics.
61 stars 15 forks source link

Testing for numeric data #5

Closed paulstey closed 8 years ago

paulstey commented 8 years ago

Hello Carlos,

When you are testing whether or not the data supplied to extract.digits() is numeric data, I think you should be using is.numeric(). As it stands now, the use of class(data) != "numeric" produces unexpected errors when the class is "integer". Consider the following:

library(benford.analysis)

dat <- data.frame(v1 = 1:5, v2 = c(1, 2, 3, 4, 5))

benford(dat$v1)          # produces error

This error is returned because while dat$v1 is clearly numeric, the call class(dat$v1) will return "integer".

On a different note, thank you for a wonderful R package!

-Paul

carloscinelli commented 8 years ago

You are right, Paul, thanks!

carloscinelli commented 8 years ago

Paul, I have just corrected the issue, the github version should be running fine now!