The cpfr package provides a simple and efficient way to validate Brazilian Individual Taxpayer Registry (CPF) numbers.
✨ Key Features
-
Accurate Validation: Implements the official verification digit algorithm.
-
Flexible: Handles formatted (e.g., 123.456.789-00) and unformatted text inputs.
-
Lightweight: No external dependencies.
🇧🇷 O cpfr é um pacote R simples e eficiente para a validação de números de Cadastro de Pessoas Físicas (CPF) do Brasil.
✨Principais características
-
Validação Precisa: Implementa o algoritmo oficial de cálculo dos dígitos verificadores.
-
Flexível: Lida com CPFs formatados (ex:
123.456.789-00) ou como texto puro. -
Leve: Sem dependências externas.
You can install the development version of cpfr from GitHub with:
# install.packages("pak")
pak::pak("gabrielmouta/cpfr")The main function, validar_cpf(), accepts a single CPF string and returns a logical value (TRUE or FALSE).
library(cpfr)
# Example 1: A valid CPF
validar_cpf("649.722.730-03")
#> [1] TRUE
# Example 2: An invalid CPF (all same digits)
validar_cpf("11111111111")
#> [1] FALSE
# You can also request a textual return
validar_cpf("12345", logical_return = FALSE)
#> [1] "CPF incorreto"