Validate, Compare and Format Identification Numbers from Brazil

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.

Travis build status

The numbersBR package aims to help with brazilian numbers used to identify companies, individuals and cars (CNPJ, CPF and RENAVAN, for example).

The package provides functions to validate, format and execute comparisons of these numbers when they come in different formats. For example, compare a numeric CPF against a character CPF. The functions are implemented in a vectorized way in order to speed up validations and comparison in large datasets.


The package can be installed directly from github using devtools.



The numbers can be created with numeric or character vectors:

> x
> is.valid(x)
[1] TRUE
> x == 13515463000138
[1] TRUE
> x <- CPF(c("681.943.594-06", "012.391.576-73", "520.082.755-82"))
> x
681.943.594-06 012.391.576-73 520.082.755-82 
> is.valid(x)
> x == 68194359406
> x <- RENAVAN(c(75320797785, 91671999129))
> is.valid(x)


For now we have CPF, CNPJ and RENAVAN implemented, so if you need another number or, even better, if you have it implemented, get in touch so we can add new numbers to the package.


Changes in Version 0.0.2

  • First stable version

  • Implements CPF, CNPJ, RENAVAN

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.0.2 by Wilson Freitas, 3 years ago

Browse source code at

Authors: Wilson Freitas [aut, cre]

Documentation:   PDF Manual  

MIT + file LICENSE license

Imports stringr

Suggests testthat

See at CRAN