Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rocnp
Title: Work with Romanian Personal Numeric Codes PNC / CNP
Version: 0.1.0.9000
Version: 0.1.0.9001
Authors@R:
person("Dragoș", "Moldovan-Grünfeld", , "dragos.mold@gmail.com", role = c("aut", "cre", "cph"))
Description: A set of tools for working with Romanian personal numeric
Expand Down
47 changes: 25 additions & 22 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@ knitr::opts_chunk$set(
[![CRAN status](https://www.r-pkg.org/badges/version/rocnp)](https://CRAN.R-project.org/package=rocnp)
<!-- badges: end -->

The goal of {rocnp} is to provide a set of functions for working with Romanian
personal numeric codes.
The goal of {rocnp} is to provide a set of functions for working with Romanian Personal Numeric Codes / Coduri Numerice Personale (CNP).

## Features

rocnp includes the following functionality for working with Romanian personal numeric codes (PNC / CNP):

* check validity using `check_cnp_is_valid()`
* decompose the code in the parts that make it up with `decompose_cnp()`
* extract the various components with the `get_()` family of functions:
* `get_birth_year()`
* `get_birth_month()`
* `get_county()`, etc.
* an S3 class called `cnp`:
* implemented as a record (similar to `POSIXlt`) with `vctrs::new_rcrd()`. The implementation details are
* a constructor, `cnp()` for creating a `cnp` object
* the constructor automatically decomposes the CNP and augments it by parsing the various field
* access the various components with the `extract_()` family of functions:
* use `extract_sex()` for sex.
* `extract_birth_year()` for the year of birth.
* `extract_birth_month()` for the month of birth.
* `extract_county()` for county of issue.
* `extract_status()` for the residence status.
* `extract_dob()` for the date of birth.

## Installation

Expand All @@ -47,8 +51,8 @@ install.packages("rocnp")
Alternatively, if you need the development version from [GitHub](https://github.com/dragosmg/rocnp), install it with

``` r
# install.packages(devtools)
devtools::install_dev("rocnp")
# install.packages("pak")
pak::pkg_install("dragosmg/rocnp")
```

## Usage
Expand All @@ -60,18 +64,17 @@ library(rocnp)

# these are synthetically generated CNPs
# check CNP is valid
check_cnp_is_valid(1940616346114)

# split CNP into components
decompose_cnp(6201206018078)

# extract birth year
get_birth_year(1940616346114)

# extract birth month
get_birth_month(1940616346114)
cnps <- cnp(
c(
"1940616346114", "6201206018078", "1940616346114"
)
)

# extract county
get_county(6201206018078)
extract_sex(cnps)
extract_birth_year(cnps)
extract_birth_month(cnps)
extract_dob(cnps)
extract_county(cnps)
extract_status(cnps)
```

63 changes: 35 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,27 @@ status](https://www.r-pkg.org/badges/version/rocnp)](https://CRAN.R-project.org/
<!-- badges: end -->

The goal of {rocnp} is to provide a set of functions for working with
Romanian personal numeric codes.
Romanian Personal Numeric Codes / Coduri Numerice Personale (CNP).

## Features

rocnp includes the following functionality for working with Romanian
personal numeric codes (PNC / CNP):

- check validity using `check_cnp_is_valid()`
- decompose the code in the parts that make it up with `decompose_cnp()`
- extract the various components with the `get_()` family of functions:
- `get_birth_year()`
- `get_birth_month()`
- `get_county()`, etc.
- an S3 class called `cnp`:
- implemented as a record (similar to `POSIXlt`) with
`vctrs::new_rcrd()`. The implementation details are
- a constructor, `cnp()` for creating a `cnp` object
- the constructor automatically decomposes the CNP and augments it by
parsing the various field
- access the various components with the `extract_()` family of
functions:
- use `extract_sex()` for sex.
- `extract_birth_year()` for the year of birth.
- `extract_birth_month()` for the month of birth.
- `extract_county()` for county of issue.
- `extract_status()` for the residence status.
- `extract_dob()` for the date of birth.

## Installation

Expand All @@ -42,8 +50,8 @@ Alternatively, if you need the development version from
[GitHub](https://github.com/dragosmg/rocnp), install it with

``` r
# install.packages(devtools)
devtools::install_dev("rocnp")
# install.packages("pak")
pak::pkg_install("dragosmg/rocnp")
```

## Usage
Expand All @@ -56,23 +64,22 @@ library(rocnp)

# these are synthetically generated CNPs
# check CNP is valid
check_cnp_is_valid(1940616346114)
#> [1] TRUE

# split CNP into components
decompose_cnp(6201206018078)
#> S AA LL ZZ JJ NNN C
#> "6" "20" "12" "06" "01" "807" "8"

# extract birth year
get_birth_year(1940616346114)
#> [1] "1994"

# extract birth month
get_birth_month(1940616346114)
#> [1] 6

# extract county
get_county(6201206018078)
#> [1] "Alba"
cnps <- cnp(
c(
"1940616346114", "6201206018078", "1940616346114"
)
)

extract_sex(cnps)
#> [1] "M" "F" "M"
extract_birth_year(cnps)
#> [1] "1994" "2020" "1994"
extract_birth_month(cnps)
#> [1] "06" "12" "06"
extract_dob(cnps)
#> [1] "1994-06-16" "2020-12-06" "1994-06-16"
extract_county(cnps)
#> [1] "Teleorman" "Alba" "Teleorman"
extract_status(cnps)
#> [1] "native" "native" "native"
```
Loading