Title: | Validate, Compare and Format Identification Numbers from Brazil |
Version: | 0.0.2 |
Description: | Validate, format and compare identification numbers used in Brazil. These numbers are used to identify individuals (CPF), vehicles (RENAVAN), companies (CNPJ) and etc. Functions to format, validate and compare these numbers have been implemented in a vectorized way in order to speed up validations and comparisons in big datasets. |
Depends: | R (≥ 3.2.2) |
License: | MIT + file LICENSE |
LazyData: | true |
RoxygenNote: | 6.0.1 |
Imports: | stringr |
Suggests: | testthat |
Collate: | 'util.R' 'CNPJ.R' 'CPF.R' 'RENAVAN.R' 'numbersBR.R' |
NeedsCompilation: | no |
Packaged: | 2018-03-31 14:58:26 UTC; wilson |
Author: | Wilson Freitas [aut, cre] |
Maintainer: | Wilson Freitas <wilson.freitas@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2018-04-05 11:32:17 UTC |
Validate, Compare and Format Identification Numbers From Brazil.
Description
This package helps handling identification numbers used in Brazil. These numbers are used to identify individuals (CPF), vehicles (RENAVAN), companies (CNPJ) and etc. Functions to format, validate and compare these numbers have been implemented in a vectorized way in order to speed up validations and comparisons in big datasets.
Author(s)
Wilson Freitas
Compare numbers among themselves, with numeric and character objects.
Description
Compares the brazilian numbers among themselves, with numeric and character objects.
Usage
## S3 method for class 'CNPJ'
e1 == e2
## S3 method for class 'CNPJ'
e1 != e2
## S3 method for class 'CPF'
e1 == e2
## S3 method for class 'CPF'
e1 != e2
## S3 method for class 'RENAVAN'
e1 == e2
## S3 method for class 'RENAVAN'
e1 != e2
Arguments
e1 |
the identification number class. |
e2 |
the object to be compared with, can be of the same type of |
Value
A logical vector indicating that the given objects represent the same number.
Examples
x <- CNPJ(13515463000138)
x == '13515463000138'
x <- CPF(68194359406)
x != "681.943.594-06"
x <- RENAVAN(68194359406)
x == "68194359406"
Functions to create brazilian numbers objects
Description
The brazilian numbers used to identify individuals, vehicles, companies and any other things have their own S3 classes.
Usage
CNPJ(x)
CPF(x)
RENAVAN(x)
Arguments
x |
the identification number as numeric or character |
Value
A S3 class representing the brazilian number: CNPJ, CPF, RENAVAN
Examples
CNPJ(c(13515463000138, 3737211000108, 360305000104, 66670000100))
CNPJ(c("13.515.463/0001-38", "03.737.211/0001-08", "00.360.305/0001-04", "00.066.670/0001-00"))
CPF(c(68194359406, 1239157673, 52008275582))
CPF(c("681.943.594-06", "012.391.576-73", "520.082.755-82"))
RENAVAN(c(75320797785, 91671999129, 60885589380))
Format numbers
Description
Formats the brazilian numbers according to their specific format.
Usage
## S3 method for class 'CNPJ'
format(x, format = c("strict", "stripped"), ...)
## S3 method for class 'CPF'
format(x, format = c("strict", "stripped"), ...)
## S3 method for class 'RENAVAN'
format(x, ...)
Arguments
x |
the identification number class. |
format |
can be strict which is the default format with all dots, dashes and hyphens or stripped which returns only the numbers. |
... |
arguments to be passed to or from other methods. |
Value
A character vector with the formatted number.
Examples
x <- CNPJ(66670000100)
format(x)
format(x, "stripped")
x <- CPF(1239157673)
format(x)
format(x, "stripped")
x <- RENAVAN("68194359406")
format(x)
Validate numbers
Description
Validates the brazilian numbers when it is necessary. Not all identification numbers don't have a validation algorithm.
Usage
is.valid(x)
## S3 method for class 'CNPJ'
is.valid(x)
## S3 method for class 'CPF'
is.valid(x)
## S3 method for class 'RENAVAN'
is.valid(x)
Arguments
x |
the identification number class. |
Value
A logical vector indicating whether the number is valid or not.
Examples
is.valid(CNPJ(c(13515463000138, 66670000101))) # TRUE, FALSE
is.valid(CPF(c(1239157673, 42752486198))) # TRUE, FALSE
is.valid(RENAVAN(c(75320797785, 42752486198))) # TRUE, FALSE